From 6d74d9fa63bc478fcd56a2edf4bdb9906efa1966 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 24 Mar 2022 21:12:43 -0400 Subject: latex header, work on (& some code formatting) --- org/out_latex.org | 831 +++++++++++++++++++++++++++--------------------------- 1 file changed, 421 insertions(+), 410 deletions(-) (limited to 'org/out_latex.org') diff --git a/org/out_latex.org b/org/out_latex.org index bac3158..817bbc8 100644 --- a/org/out_latex.org +++ b/org/out_latex.org @@ -27,95 +27,93 @@ <> module doc_reform.io_out.latex; template outputLaTeX() { - <> - mixin InternalMarkup; // watch - mixin spineRgxOut; - static auto rgx = RgxO(); - mixin spineLanguageCodes; - auto lang = Lang(); - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> -<> -<> -<> -<> -<> -<> -<> - <> - <> - <> - <> - <> - <> - <> -<> -<> - <> - <> - <> - <> -<> - <> - <> -<> - <> - <> -<> - <> - <> -<> - <> - <> - <> - <> - <> -<> -<> -<> -<> -<> -<> -<> -<> -<> -<> -<> -<> -<> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> - <> -<> - <> - <> - <> - <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> +<> +<> +<> +<> +<> + <> +<> + <> + <> + <> + <> + <> + <> + <> +<> +<> + <> + <> + <> + <> +<> + <> + <> +<> + <> + <> +<> + <> + <> +<> + <> + <> + <> + <> + <> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +%% <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> +<> + <> + <> + <> + <> } #+END_SRC ** write latex output :latex:out: -#+NAME: output_latex_output_write +#+NAME: Function_output_write #+BEGIN_SRC d void writeOutputLaTeX(T,M)( const T latex_content, @@ -157,7 +155,7 @@ void writeOutputLaTeX(T,M)( ** latex output hub [#A] :latex:pdf:out: -#+NAME: output_latex_output_set +#+NAME: Function_output_set #+BEGIN_SRC d void outputLaTeX(D,M)( const D doc_abstraction, @@ -181,7 +179,7 @@ void outputLaTeX(D,M)( * stuff ** output imports -#+NAME: output_latex_imports +#+NAME: ImportsAndMixins_imports #+BEGIN_SRC d import std.digest.sha, @@ -190,12 +188,17 @@ import std.uri, std.conv : to; import doc_reform.io_out; +mixin InternalMarkup; // watch +mixin spineRgxOut; +static auto rgx = RgxO(); +mixin spineLanguageCodes; +auto lang = Lang(); #+END_SRC ** shared *** paper dimensions (struct) geometry -#+NAME: output_latex_shared_geometry_paper_dimensions +#+NAME: Function_shared_geometry_paper_dimensions #+BEGIN_SRC d auto paper() { string mm(uint mmi) { @@ -456,7 +459,7 @@ auto paper() { *** latex \escape special characters **** general -#+NAME: output_latex_shared_special_characters_to_escape_object +#+NAME: Function_shared_special_characters_to_escape_object #+BEGIN_SRC d @safe string sp_char_esc(O)( string _txt, @@ -485,7 +488,7 @@ auto paper() { } #+END_SRC -#+NAME: output_latex_shared_special_characters_to_escape_text +#+NAME: Function_shared_special_characters_to_escape_text #+BEGIN_SRC d @safe string sp_char_esc_txt()( string _txt, @@ -527,7 +530,7 @@ auto paper() { - bold, italics, underscore, strikethrough -#+NAME: output_latex_shared_fontface +#+NAME: Function_shared_fontface #+BEGIN_SRC d @safe string fontface()( string _txt, @@ -550,7 +553,7 @@ _txt = _txt **** spaces ***** leading hardspace UNUSED -#+NAME: output_latex_shared_leading_hardspaces +#+NAME: Function_shared_leading_hardspaces #+BEGIN_SRC d @safe string leading_hardspaces()( string _txt, @@ -567,7 +570,7 @@ _txt = _txt ***** nbsp character UNUSED -#+NAME: output_latex_shared_character_nbsp_to_hardspace_ +#+NAME: shared_character_nbsp_to_hardspace_ #+BEGIN_SRC d @safe string nbsp_char_replace()(string _txt) { if (_txt.match(rgx.nbsp_char)) { @@ -579,7 +582,7 @@ _txt = _txt ***** nbsp character -#+NAME: output_latex_shared_character_nbsp_to_hardspace +#+NAME: Function_shared_character_nbsp_to_hardspace #+BEGIN_SRC d @safe string nbsp_char()(string _txt) { if (_txt.match(rgx.nbsp_char)) { @@ -597,7 +600,7 @@ _txt = _txt ***** keep spaces -#+NAME: output_latex_shared_character_spaces_to_hardspace +#+NAME: Function_shared_character_spaces_to_hardspace #+BEGIN_SRC d @safe string spaces_to_nbsp()(string _txt) { if (_txt.match(rgx.spaces_keep)) { @@ -615,7 +618,7 @@ _txt = _txt ***** remove nbsp character -#+NAME: output_latex_shared_character_nbsp_to_space +#+NAME: Function_shared_character_nbsp_to_space #+BEGIN_SRC d @safe string nbsp_char_to_space()(string _txt) { if (_txt.match(rgx.nbsp_char)) { @@ -628,7 +631,7 @@ _txt = _txt **** links and images ***** links / urls -#+NAME: output_latex_shared_links_and_images +#+NAME: Function_shared_links_and_images #+BEGIN_SRC d @safe string links_and_images(O,M)( string _txt, @@ -682,7 +685,7 @@ _txt = _txt *** footnotes **** footnotes -#+NAME: output_latex_shared_footnotes +#+NAME: Function_shared_footnotes #+BEGIN_SRC d @safe string footnotes()( string _txt, @@ -703,7 +706,7 @@ _txt = _txt **** footnote remove -#+NAME: output_latex_shared_footnotes_remove +#+NAME: Function_shared_footnotes_remove #+BEGIN_SRC d @safe string remove_footnotes()( string _txt, @@ -718,7 +721,7 @@ _txt = _txt *** para **** para -#+NAME: output_latex_shared_para +#+NAME: Function_shared_para #+BEGIN_SRC d @safe string para(O)( string _txt, @@ -738,7 +741,7 @@ _txt = _txt **** bookindex para -#+NAME: output_latex_shared_bookindex +#+NAME: Function_shared_bookindex #+BEGIN_SRC d @safe string bookindex(O)( string _txt, @@ -759,7 +762,7 @@ _txt = _txt *** bullets & indentation -#+NAME: output_latex_head_bullets_and_indentation +#+NAME: Function_head_bullets_and_indentation #+BEGIN_SRC d @safe string bullets_and_indentation(O)( string _txt, @@ -804,7 +807,7 @@ _txt = _txt *** heading -#+NAME: output_latex_shared_heading +#+NAME: Function_shared_heading #+BEGIN_SRC d @safe string heading(O,M)( string _txt, @@ -938,43 +941,16 @@ _txt = _txt goto default; default: if (obj.metainfo.heading_lev_markup == 0) { - _tex_para = q"┃\begin{document} -\DeclareTOCStyleEntry[numwidth+=8pt]{part}{part} -\DeclareTOCStyleEntry[numwidth+=4pt]{section}{section} -\DeclareTOCStyleEntry[numwidth+=3pt]{section}{paragraph} -\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subparagraph} -\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subsection} -\DeclareTOCStyleEntries[indent+=4pt]{section}{section,subsection,subsubsection} -\DeclareTOCStyleEntries[numwidth+=3pt]{section}{paragraph,subparagraph} -\RedeclareSectionCommand[%% - style=section, - level=0, - indent=\z@, - beforeskip=-3.5ex \@plus -1ex \@minus -.2ex, - afterskip=2.3ex \@plus.2ex, - tocindent=0pt, - tocnumwidth=1.5em - ]{part} -\RedeclareSectionCommands[%% - tocnumwidth+=4pt, - tocindent+=4pt, - style=section, - beforeskip=-0pt, - afterskip=4pt, - afterindent=false, - indent=0pt]{section,subsection,subsubsection} -\RedeclareSectionCommands[%% - beforeskip=-10pt plus -2pt minus -1pt, - afterskip=1sp plus -1sp minus 1sp, - font=\normalfont\itshape, - indent=0pt]{paragraph,subparagraph} -\title{%s} + _tex_para = q"┃ +\begin{document} +\thispagestyle{empty} +\title{%s%s} \author{ \textnormal{%s}} \date{\begin{tiny}%s\end{tiny}} -\thispagestyle{empty} \maketitle -\pagestyle{fancy} +\addcontentsline{toc}{part}{%s} \newpage +\pagestyle{fancy} \pagenumbering{alph} \setcounter{page}{1} \markboth{%s}{%s} @@ -982,10 +958,13 @@ _txt = _txt %s \clearpage┃"; _txt = format(_tex_para, - (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, + (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt, + doc_matters.conf_make_meta.meta.title_subtitle.empty ? "" + : " \\\\ - \\\\ " ~ (doc_matters.conf_make_meta.meta.title_subtitle).sp_char_esc_txt, (doc_matters.conf_make_meta.meta.creator_author).sp_char_esc_txt, (doc_matters.conf_make_meta.meta.date_published).sp_char_esc_txt, (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt, + (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt, (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, (doc_matters.conf_make_meta.meta.rights_copyright).sp_char_esc_txt, (doc_matters.conf_make_meta.meta.rights_license).sp_char_esc_txt, @@ -1025,7 +1004,7 @@ _txt = _txt \markboth{%s}{%s} %% \null \clearpage -\setcounter{page}{1}┃"; +\setcounter{page}{2}┃"; _txt = format(_tex_para, (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, (doc_matters.conf_make_meta.meta.creator_author).sp_char_esc_txt, @@ -1080,105 +1059,105 @@ _txt = _txt - (hardspace not honored) clear hardspace marker -#+NAME: output_latex_shared_group +#+NAME: Function_shared_group #+BEGIN_SRC d -string group(O,M)( - string _txt, - O obj, - M doc_matters, -) { - if (obj.metainfo.is_a == "group") { - string _tex_para; - _tex_para = q"┃\ocn{%s}\objGroupOpen + string group(O,M)( + string _txt, + O obj, + M doc_matters, + ) { + if (obj.metainfo.is_a == "group") { + string _tex_para; + _tex_para = q"┃\ocn{%s}\objGroupOpen %s \objGroupClose ┃"; - _txt = format(_tex_para, - obj.metainfo.object_number, - _txt.footnotes.split(rgx.br_line_spaced).join("\\brl{1}").strip // provides more control (more noise, not as tidy) - // _txt.footnotes.split(rgx.br_line_spaced).join("") // this works using a line-space, looks tidy, keep ref. - ).strip; + _txt = format(_tex_para, + obj.metainfo.object_number, + _txt.footnotes.split(rgx.br_line_spaced).join("\\brl{1}").strip // provides more control (more noise, not as tidy) + // _txt.footnotes.split(rgx.br_line_spaced).join("") // this works using a line-space, looks tidy, keep ref. + ).strip; + } + return _txt; } - return _txt; -} #+END_SRC **** block - (hardspace honored) \hardspace -#+NAME: output_latex_shared_block +#+NAME: Function_shared_block #+BEGIN_SRC d -string block(O,M)( - string _txt, - O obj, - M doc_matters, -) { - if (obj.metainfo.is_a == "block") { - string _tex_para; - _tex_para = q"┃\ocn{%s}\objBlockOpen + string block(O,M)( + string _txt, + O obj, + M doc_matters, + ) { + if (obj.metainfo.is_a == "block") { + string _tex_para; + _tex_para = q"┃\ocn{%s}\objBlockOpen %s \objBlockClose ┃"; - _txt = format(_tex_para, - obj.metainfo.object_number, - _txt.nbsp_char.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip - ).strip; + _txt = format(_tex_para, + obj.metainfo.object_number, + _txt.nbsp_char.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip + ).strip; + } + return _txt; } - return _txt; -} #+END_SRC **** (poem) verse - (hardspace honored) \hardspace -#+NAME: output_latex_shared_verse +#+NAME: Function_shared_verse #+BEGIN_SRC d -string verse(O,M)( - string _txt, - O obj, - M doc_matters, -) { - if (obj.metainfo.is_a == "verse") { - string _tex_para; - _tex_para = q"┃\ocn{%s}\objPoemVerseOpen + string verse(O,M)( + string _txt, + O obj, + M doc_matters, + ) { + if (obj.metainfo.is_a == "verse") { + string _tex_para; + _tex_para = q"┃\ocn{%s}\objPoemVerseOpen %s \objPoemVerseClose ┃"; - _txt = format(_tex_para, - obj.metainfo.object_number, - _txt.spaces_to_nbsp.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip - ).strip; + _txt = format(_tex_para, + obj.metainfo.object_number, + _txt.spaces_to_nbsp.footnotes.split(rgx.br_linebreaks_newlines).join("\\br\n").strip + ).strip; + } + return _txt; } - return _txt; -} #+END_SRC **** codeblock - (hardspace honored) \begin{lstlisting} clear hardspace marker -#+NAME: output_latex_shared_codeblock +#+NAME: Function_shared_codeblock #+BEGIN_SRC d -string codeblock(O,M)( - string _txt, - O obj, - M doc_matters, -) { - if (obj.metainfo.is_a == "code") { - string _tex_para; - _tex_para = q"┃\ocn{%s}\begin{objCodeBlock}\begin{lstlisting} + string codeblock(O,M)( + string _txt, + O obj, + M doc_matters, + ) { + if (obj.metainfo.is_a == "code") { + string _tex_para; + _tex_para = q"┃\ocn{%s}\begin{objCodeBlock}\begin{lstlisting} %s \end{lstlisting}\end{objCodeBlock} ┃"; - _txt = format(_tex_para, - obj.metainfo.object_number, - _txt.nbsp_char_to_space - ).strip; + _txt = format(_tex_para, + obj.metainfo.object_number, + _txt.nbsp_char_to_space + ).strip; + } + return _txt; } - return _txt; -} #+END_SRC **** table @@ -1187,7 +1166,7 @@ string codeblock(O,M)( ***** tablarize -#+NAME: output_latex_shared_tablarize +#+NAME: Function_shared_tablarize #+BEGIN_SRC d auto tablarize(O)( string _txt, @@ -1226,61 +1205,61 @@ auto tablarize(O)( ***** table -#+NAME: output_latex_shared_table +#+NAME: Function_shared_table #+BEGIN_SRC d -string table(O,M)( - string _txt, - O obj, - M doc_matters, - string paper_size_orientation, -) { - if (obj.metainfo.is_a == "table") { - auto _t = _txt.tablarize(obj); - string _table = _t[0]; - string _t_n = _t[1]; - uint pw = 0; - switch (paper_size_orientation) { - case "a4.portrait": pw = (paper.a4.portrait.w - 20); break; - case "a4.landscape": pw = (paper.a4.landscape.w - 20); break; - case "b4.portrait": pw = (paper.b4.portrait.w - 20); break; - case "b4.landscape": pw = (paper.b4.landscape.w - 20); break; - case "a5.portrait": pw = (paper.a5.portrait.w - 20); break; - case "a5.landscape": pw = (paper.a5.landscape.w - 20); break; - case "letter.portrait": pw = (paper.letter.portrait.w - 20); break; - case "letter.landscape": pw = (paper.letter.landscape.w - 20); break; - case "legal.portrait": pw = (paper.legal.portrait.w - 20); break; - case "legal.landscape": pw = (paper.legal.landscape.w - 20); break; - default: pw = 0; break; - } - // auto textwidth = (pw - 24); - string _colw = ""; - foreach (w; obj.table.column_widths) { - _colw ~= format(q"┃p{%.0fmm}┃", - (w * pw / 100) - // (w * (pw - 24)/ 100) - // (w * textwidth / 100) - ); - } - string _tex_para; - _tex_para = q"┃\ocn{%s}\objTableOpen{%s} + string table(O,M)( + string _txt, + O obj, + M doc_matters, + string paper_size_orientation, + ) { + if (obj.metainfo.is_a == "table") { + auto _t = _txt.tablarize(obj); + string _table = _t[0]; + string _t_n = _t[1]; + uint pw = 0; + switch (paper_size_orientation) { + case "a4.portrait": pw = (paper.a4.portrait.w - 20); break; + case "a4.landscape": pw = (paper.a4.landscape.w - 20); break; + case "b4.portrait": pw = (paper.b4.portrait.w - 20); break; + case "b4.landscape": pw = (paper.b4.landscape.w - 20); break; + case "a5.portrait": pw = (paper.a5.portrait.w - 20); break; + case "a5.landscape": pw = (paper.a5.landscape.w - 20); break; + case "letter.portrait": pw = (paper.letter.portrait.w - 20); break; + case "letter.landscape": pw = (paper.letter.landscape.w - 20); break; + case "legal.portrait": pw = (paper.legal.portrait.w - 20); break; + case "legal.landscape": pw = (paper.legal.landscape.w - 20); break; + default: pw = 0; break; + } + // auto textwidth = (pw - 24); + string _colw = ""; + foreach (w; obj.table.column_widths) { + _colw ~= format(q"┃p{%.0fmm}┃", + (w * pw / 100) + // (w * (pw - 24)/ 100) + // (w * textwidth / 100) + ); + } + string _tex_para; + _tex_para = q"┃\ocn{%s}\objTableOpen{%s} %s \objTableClose ┃"; - _txt = format(_tex_para, - obj.metainfo.object_number, - _colw, - _table, - ).strip; + _txt = format(_tex_para, + obj.metainfo.object_number, + _colw, + _table, + ).strip; + } + return _txt; } - return _txt; -} #+END_SRC ** latex parts *** latex head :head: **** latex head function -#+NAME: output_latex_head +#+NAME: MethodOpen_head #+BEGIN_SRC d string latex_head(M)( M doc_matters, @@ -1292,7 +1271,7 @@ string latex_head(M)( ***** paper type dimensions ****** struct -#+NAME: output_latex_head_papertype +#+NAME: Struct_head_papertype #+BEGIN_SRC d struct paperTypeLatex { string a4_portrait; @@ -1311,7 +1290,7 @@ auto paper_type_latex = paperTypeLatex(); ****** footer -#+NAME: output_latex_head_footer +#+NAME: Function_head_footer #+BEGIN_SRC d string _footer(M)(M doc_matters) { string _ft = "\\lfoot[\\textrm{\\thepage}]"; @@ -1346,7 +1325,7 @@ string _footer(M)(M doc_matters) { ***** paper margins ****** struct -#+NAME: output_latex_head_tex_papermargins +#+NAME: Struct_head_tex_papermargins #+BEGIN_SRC d struct paperMargins { string portrait; @@ -1358,7 +1337,7 @@ auto margins = paperMargins(); ***** multicol ****** struct -#+NAME: output_latex_head_tex_columns_multi +#+NAME: Struct_head_tex_columns_multi #+BEGIN_SRC d struct columnsMulti { string portrait; @@ -1369,25 +1348,25 @@ auto multicol = columnsMulti(); ****** portrait -#+NAME: output_latex_head_tex_columns_multi_portrait +#+NAME: FmtTxtOpen_head_tex_columns_multi_portrait #+BEGIN_SRC d multicol.portrait = format(q"┃ #+END_SRC -#+NAME: output_latex_head_tex_columns_multi_portrait_set +#+NAME: FmtTxtSet_head_tex_columns_multi_portrait #+BEGIN_SRC latex \usepackage{multicol} #+END_SRC -#+NAME: output_latex_head_tex_columns_multi_portrait_close +#+NAME: FmtTxtClose_head_tex_columns_multi_portrait #+BEGIN_SRC d ┃", - ); + ); #+END_SRC ****** landscape -#+NAME: output_latex_head_tex_columns_multi_landscape +#+NAME: VarSet_head_tex_columns_multi_landscape #+BEGIN_SRC d multicol.landscape = ""; #+END_SRC @@ -1395,7 +1374,7 @@ multicol.landscape = ""; ***** color links ****** struct -#+NAME: output_latex_head_tex_colorlinks +#+NAME: Struct_head_tex_colorlinks #+BEGIN_SRC d struct colorLinks { string mono; @@ -1406,12 +1385,12 @@ auto links = colorLinks(); ****** mono -#+NAME: output_latex_head_tex_colorlinks_mono +#+NAME: FmtTxtOpen_head_tex_colorlinks_mono #+BEGIN_SRC d links.mono = format(q"┃ #+END_SRC -#+NAME: output_latex_head_tex_colorlinks_mono_set +#+NAME: FmtTxtSet_head_tex_colorlinks_mono #+BEGIN_SRC latex colorlinks=true, urlcolor=black, @@ -1420,20 +1399,20 @@ linkcolor=black, citecolor=black, #+END_SRC -#+NAME: output_latex_head_tex_colorlinks_mono_close +#+NAME: FmtTxtClose_head_tex_colorlinks_mono #+BEGIN_SRC d ┃", - ); + ); #+END_SRC ****** color -#+NAME: output_latex_head_tex_colorlinks_color +#+NAME: FmtTxtOpen_head_tex_colorlinks_color #+BEGIN_SRC d links.color = format(q"┃ #+END_SRC -#+NAME: output_latex_head_tex_colorlinks_color_set +#+NAME: FmtTxtSet_head_tex_colorlinks_color #+BEGIN_SRC latex colorlinks=true, urlcolor=myblue, %% \href{...}{...} external url @@ -1442,31 +1421,31 @@ linkcolor=myred, %% \href{...} and \pageref{...} citecolor=black, #+END_SRC -#+NAME: output_latex_head_tex_colorlinks_color_close +#+NAME: FmtTxtClose_head_tex_colorlinks_color #+BEGIN_SRC d ┃", - ); + ); #+END_SRC **** latex head starts ***** dimensions & orientation ****** set -#+NAME: output_latex_head_format_string_paper_set +#+NAME: MethodOpen_head_format_string_paper_set #+BEGIN_SRC d string set_paper(P)(P paper_set,) { string paper_type_description; #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_format_portrait +#+NAME: Condition_FmtTxtOpen_head_format_string_paper_set_format_portrait #+BEGIN_SRC d if (paper_set.is_portrait) { paper_type_description = format(q"┃ #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_format_portrait_tex -#+BEGIN_SRC d -\documentclass[%s,%s,titlepage]{scrartcl} +#+NAME: FmtTxtSet_head_format_string_paper_set_format_portrait_tex +#+BEGIN_SRC latex +\documentclass[%s,%s,titlepage,makeidx]{scrartcl} \usepackage{geometry} \geometry{ %s, @@ -1478,7 +1457,7 @@ if (paper_set.is_portrait) { }┃", #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_format_portrait_variables +#+NAME: FmtTxtClose_head_format_string_paper_set_format_portrait_variables #+BEGIN_SRC d paper_set.fontsize, paper_set.papersize, @@ -1491,15 +1470,15 @@ if (paper_set.is_portrait) { ); #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_format_landscape +#+NAME: Condition_FmtTxtOpen_head_format_string_paper_set_format_landscape #+BEGIN_SRC d } else { paper_type_description = format(q"┃ #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_format_landscape_tex +#+NAME: FmtTxtSet_head_format_string_paper_set_format_landscape_tex #+BEGIN_SRC d -\documentclass[%s,%s,landscape,titlepage,twocolumn]{scrartcl} +\documentclass[%s,%s,landscape,titlepage,twocolumn,makeidx]{scrartcl} \usepackage{geometry} \geometry{ %s, @@ -1511,7 +1490,7 @@ if (paper_set.is_portrait) { }┃", #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_format_landscape_variables +#+NAME: FmtTxtClose_head_format_string_paper_set_format_landscape_variables #+BEGIN_SRC d paper_set.fontsize, paper_set.papersize, @@ -1524,7 +1503,7 @@ if (paper_set.is_portrait) { ); #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_return +#+NAME: MethodClose_head_format_string_paper_set_return #+BEGIN_SRC d } return paper_type_description; @@ -1537,27 +1516,27 @@ if (paper_set.is_portrait) { $SpineBIN/spine --verbose --latex --set-papersize="a4,letter.portrait,b4.portrait" --output="$SpineOUT" $SpinePOD/* #+END_SRC -#+NAME: output_latex_head_format_string_paper_set_orientation +#+NAME: Switch_head_format_string_paper_set_orientation #+BEGIN_SRC d string paper_size_orientation_latex; switch (paper_size_orientation) { -case "a4.portrait": paper_size_orientation_latex = set_paper(paper.a4.portrait); break; -case "a4.landscape": paper_size_orientation_latex = set_paper(paper.a4.landscape); break; -case "b4.portrait": paper_size_orientation_latex = set_paper(paper.b4.portrait); break; -case "b4.landscape": paper_size_orientation_latex = set_paper(paper.b4.landscape); break; -case "a5.portrait": paper_size_orientation_latex = set_paper(paper.a5.portrait); break; -case "a5.landscape": paper_size_orientation_latex = set_paper(paper.a5.landscape); break; -case "letter.portrait": paper_size_orientation_latex = set_paper(paper.letter.portrait); break; -case "letter.landscape": paper_size_orientation_latex = set_paper(paper.letter.landscape); break; -case "legal.portrait": paper_size_orientation_latex = set_paper(paper.legal.portrait); break; -case "legal.landscape": paper_size_orientation_latex = set_paper(paper.legal.landscape); break; -default: paper_size_orientation_latex = paper_type_latex.a4_portrait; + case "a4.portrait": paper_size_orientation_latex = set_paper(paper.a4.portrait); break; + case "a4.landscape": paper_size_orientation_latex = set_paper(paper.a4.landscape); break; + case "b4.portrait": paper_size_orientation_latex = set_paper(paper.b4.portrait); break; + case "b4.landscape": paper_size_orientation_latex = set_paper(paper.b4.landscape); break; + case "a5.portrait": paper_size_orientation_latex = set_paper(paper.a5.portrait); break; + case "a5.landscape": paper_size_orientation_latex = set_paper(paper.a5.landscape); break; + case "letter.portrait": paper_size_orientation_latex = set_paper(paper.letter.portrait); break; + case "letter.landscape": paper_size_orientation_latex = set_paper(paper.letter.landscape); break; + case "legal.portrait": paper_size_orientation_latex = set_paper(paper.legal.portrait); break; + case "legal.landscape": paper_size_orientation_latex = set_paper(paper.legal.landscape); break; + default: paper_size_orientation_latex = paper_type_latex.a4_portrait; } #+END_SRC ***** set color links -#+NAME: output_latex_head_format_string_paper_set_color +#+NAME: ConditionalSetVar_head_format_string_paper_set_color #+BEGIN_SRC d string links_mono_or_color_set = links.mono.strip; if ( @@ -1575,14 +1554,14 @@ if ( ***** format latex head, open -#+NAME: output_latex_head_format_tex_set_start_latex_head +#+NAME: FmtTxtOpen_head_format_tex_set_start_latex_head #+BEGIN_SRC d string _latex_head = format(q"┃%%%% spine LaTeX output #+END_SRC ***** description comment -#+NAME: output_latex_head_tex_set_generated_by +#+NAME: FmtTxtSet_head_tex_set_generated_by #+BEGIN_SRC latex %%%% Generated by: %s %%%% D version: %s @@ -1597,7 +1576,7 @@ string _latex_head = format(q"┃%%%% spine LaTeX output - paper_type_latex.us_letter_portrait - paper_type_latex.us_letter_landscape -#+NAME: output_latex_head_tex_set_paper_type +#+NAME: FmtTxtSet_head_tex_set_paper_type #+BEGIN_SRC latex %s #+END_SRC @@ -1607,29 +1586,29 @@ string _latex_head = format(q"┃%%%% spine LaTeX output - margins.portrait - margins.landscape -#+NAME: output_latex_head_tex_set_orintation +#+NAME: FmtTxtSet_head_tex_set_orintation #+BEGIN_SRC latex %s #+END_SRC -***** margin shared +***** multicol (portrait | landscape) -#+NAME: output_latex_head_tex_set_margins +#+NAME: FmtTxtSet_head_tex_set_columns #+BEGIN_SRC latex -\setlength{\marginparsep}{4mm} -\setlength{\marginparwidth}{8mm} +%s #+END_SRC -***** multicol (portrait | landscape) +***** margin shared -#+NAME: output_latex_head_tex_set_columns +#+NAME: FmtTxtSet_head_tex_set_margins #+BEGIN_SRC latex -%s +\setlength{\marginparsep}{4mm} +\setlength{\marginparwidth}{8mm} #+END_SRC ***** language & font -#+NAME: output_latex_head_tex_set_usepackages_languages_and_font +#+NAME: FmtTxtSet_head_tex_set_usepackages_languages_and_font #+BEGIN_SRC latex \usepackage[T1]{fontenc} %% \usepackage[utf8]{inputenc} @@ -1647,7 +1626,7 @@ string _latex_head = format(q"┃%%%% spine LaTeX output ***** latex head -#+NAME: output_latex_head_tex_set_usepackages_1 +#+NAME: FmtTxtSet_head_tex_set_usepackages_1 #+BEGIN_SRC latex \usepackage{alltt} \usepackage{hyperref} @@ -1656,8 +1635,10 @@ string _latex_head = format(q"┃%%%% spine LaTeX output ***** hyperref metadata -#+NAME: output_latex_head_tex_set_metadata +#+NAME: FmtTxtSet_head_tex_set_metadata #+BEGIN_SRC latex + unicode=true, + pdfusetitle, pdftitle={%s}, pdfauthor={%s}, pdfsubject={%s}, @@ -1668,8 +1649,13 @@ string _latex_head = format(q"┃%%%% spine LaTeX output pdffitwindow=false, %% window fit to page when opened pdfstartview={FitH}, %% fits the width of the page to the window pdfnewwindow=true, %% links in new window + pdfborder={0 0 1}, plainpages=false, %% was true + bookmarks=true, bookmarksopen=false, + bookmarksnumbered=false, + backref=false, + breaklinks=false, %% colorlinks=true, %% urlcolor=black, %% filecolor=black, @@ -1692,7 +1678,7 @@ string _latex_head = format(q"┃%%%% spine LaTeX output ***** define colors -#+NAME: output_latex_head_tex_set_colors +#+NAME: FmtTxtSet_head_tex_set_colors #+BEGIN_SRC latex \usepackage[usenames]{color} \definecolor{myblack}{rgb}{0,0,0} @@ -1708,82 +1694,46 @@ string _latex_head = format(q"┃%%%% spine LaTeX output ***** latex head -#+NAME: output_latex_head_tex_set_usepackage_misc +#+NAME: FmtTxtSet_head_tex_set_usepackage_misc #+BEGIN_SRC latex \usepackage{textcomp} \usepackage[parfill]{parskip} \usepackage[normalem]{ulem} \usepackage{soul} \usepackage{longtable} -\usepackage[tc]{titlepic} \usepackage{graphicx} -\makeatletter -\parindent{0pt} +\usepackage[tc]{titlepic} \usepackage{amssymb} \usepackage{listings} -\usepackage{color} -\usepackage{textcomp} \setcounter{secnumdepth}{2} \setcounter{tocdepth}{4} +\usepackage{bookmark} +\usepackage{microtype} \makeatletter #+END_SRC ***** indent, bullet, list -#+NAME: output_latex_head_tex_set_indent_bullet_list +#+NAME: FmtTxtSet_head_tex_set_indent_bullet_list #+BEGIN_SRC latex \usepackage[multiple,ragged]{footmisc} \setlength\footnotemargin{12pt} \usepackage[para]{manyfoot} \DeclareNewFootnote{A} -\newenvironment{ParagraphIndent}[1]%% -{ -\begin{list}{}{%% -\setlength\topsep{0pt}%% -\addtolength{\leftmargin}{#1} -\setlength\parsep{0pt plus 1pt}%% -} -\item[] -} -{\end{list}} -\newenvironment{ParagraphHang}[2]%% -{ -\begin{list}{}{%% -\setlength\topsep{0pt}%% -\addtolength{\leftmargin}{#1} -\itemindent=#2 -\setlength\parsep{0pt plus 1pt}%% -} -\item[] -} -{\end{list}} -\newenvironment{Bullet}[1]%% -{ -\begin{list}{}{%% -\setlength\topsep{0pt}%% -\addtolength{\leftmargin}{#1} -\itemindent=-1em -\setlength\parsep{0pt plus 1pt}%% -} -\item[] -$\txtbullet$\hspace{\enspace} -} -{\end{list}} #+END_SRC %%\DeclareNewFootnote[para]{A} ***** part, section, subsection, subsubsection, paragraph, subparagraph -#+NAME: output_latex_head_tex_set_part_section_subsection_subsubsection_paragraph_subparagraph +#+NAME: FmtTxtSet_head_tex_set_part_section_subsection_subsubsection_paragraph_subparagraph #+BEGIN_SRC latex \usepackage{fancyhdr} -\lhead{} #+END_SRC ***** latex head misc. including defined commands -#+NAME: output_latex_head_tex_set_misc +#+NAME: FmtTxtSet_head_tex_set_misc #+BEGIN_SRC latex \selectlanguage{%s} \lhead[ ]{ } @@ -1791,15 +1741,83 @@ $\txtbullet$\hspace{\enspace} \rhead[ ]{ } %s \rfoot[\tiny \href{}{}]{\textrm{\thepage}} -\tolerance=300 -\clubpenalty=300 -\widowpenalty=300 -\makeatother +%% \tolerance=300 +%% \clubpenalty=300 +%% \widowpenalty=300 \makeatother \chardef\txtbullet="2022 \chardef\tilde="7E \def\asterisk{{\rm \char42} } \definecolor{Light}{gray}{.92} +\definecolor{listinggray}{gray}{0.9} +\definecolor{lbcolor}{rgb}{0.9,0.9,0.9} +\lstset{ + backgroundcolor=\color{lbcolor}, + tabsize=4, + rulecolor=, + language=, + basicstyle={\ttfamily\scriptsize}, + upquote=true, + columns=fixed, + showstringspaces=false, + extendedchars=true, + breaklines=true, + prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}}, + frame=single, + showtabs=false, + showspaces=false, + showstringspaces=false, + identifierstyle=\ttfamily, + keywordstyle=\color[rgb]{0,0,1}, + commentstyle=\color[rgb]{0.133,0.545,0.133}, + stringstyle=\color[rgb]{0.627,0.126,0.941}, +} +\DeclareTOCStyleEntry[numwidth+=8pt]{part}{part} +\DeclareTOCStyleEntry[numwidth+=4pt]{section}{section} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{paragraph} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subparagraph} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subsection} +\DeclareTOCStyleEntries[indent+=4pt]{section}{section,subsection,subsubsection} +\DeclareTOCStyleEntries[numwidth+=3pt]{section}{paragraph,subparagraph} +#+END_SRC + +***** latex head new environment + +#+NAME: FmtTxtSet_head_tex_newEnvironment +#+BEGIN_SRC latex +\newenvironment{ParagraphIndent}[1]{%% + \begin{list}{}{%% + \setlength\topsep{0pt}%% + \addtolength{\leftmargin}{#1} + \setlength\parsep{0pt plus 1pt}%% + } + \item[] +} {\end{list}} +\newenvironment{ParagraphHang}[2]{%% + \begin{list}{}{%% + \setlength\topsep{0pt}%% + \addtolength{\leftmargin}{#1} + \itemindent=#2 + \setlength\parsep{0pt plus 1pt}%% + } + \item[] +} {\end{list}} +\newenvironment{Bullet}[1]{%% + \begin{list}{}{%% + \setlength\topsep{0pt}%% + \addtolength{\leftmargin}{#1} + \itemindent=-1em + \setlength\parsep{0pt plus 1pt}%% + } + \item[] + $\txtbullet$\hspace{\enspace} +} {\end{list}} +#+END_SRC + +***** latex head new commands defined + +#+NAME: FmtTxtSet_head_tex_newCommands +#+BEGIN_SRC latex \newcommand{\monosp}[1]{\normaltext\ttfamily\texbackslash#1} \newcommand{\br}{\hfill\break} \newcommand{\brl}[1]{%% @@ -1810,19 +1828,19 @@ $\txtbullet$\hspace{\enspace} \fi } \newcommand{\brln}{\hspace*{\fill}\linebreak} -\newcomand{\objBlockOpen}{ +\newcommand{\objBlockOpen}{ \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}\raggedright \begin{footnotesize} } -\newcomand{\objBlockClose}{%% +\newcommand{\objBlockClose}{%% \end{footnotesize} \setlength{\parskip}{1ex plus0.5ex minus0.2ex} } -\newcomand{\objGroupOpen}{%% +\newcommand{\objGroupOpen}{%% \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex} \begin{footnotesize} } -\newcomand{\objGroupClose}{%% +\newcommand{\objGroupClose}{%% \end{footnotesize} } \newcommand{\objPoemVerseOpen}{%% @@ -1836,12 +1854,13 @@ $\txtbullet$\hspace{\enspace} \setlength{\parskip}{1ex plus0.5ex minus0.2ex} \linebreak } -\newcommand{\parasep}{\smallskip \begin{center}*\hspace{2em}*\hspace{2em}*\end{center} \br} +\newcommand{\parasep}{%% + \smallskip \begin{center}*\hspace{2em}*\hspace{2em}*\end{center} \br +} \newcommand{\spaces}[1]{{\hspace*{#1ex}}} \newcommand{\s}{\hspace*{1ex}} \newcommand{\hardspace}{\hspace*{1ex}} \newcommand{\-}{\hspace*{1ex}} -\newcommand{\..}{\hspace*{1ex}} %% dots trailing \newcommand{\caret}{{\^{~}}} \newcommand{\pipe}{{\textbar}} \newcommand{\curlyOpen}{{} @@ -1851,18 +1870,25 @@ $\txtbullet$\hspace{\enspace} \newcommand{\slash}{{/}} \newcommand{\underscore}{\_} \newcommand{\exclaim}{\Verbatim{!}} -\newcommand{\linktext}[2]{{\href{#1} -{\ulcorner\textup{{#2}}\lrcorner}}} -\newcommand{\linkurl}[2]{{\href{#1} -{\scriptsize\ttfamily\ulcorner\textup{{#2}}\lrcorner}}} -\newcommand{\link}[2]{{\begin{scriptsize}\color{black}\urlstyle{tt}\href{#1} -{\ulcorner{#2}\lrcorner}\end{scriptsize}}} +\newcommand{\linktext}[2]{%% + {\href{#1} + {\;\ulcorner\,\textup{{#2}}\,\lrcorner}} +} +\newcommand{\linkurl}[2]{%% + \;{\href{#1} + {\;\scriptsize\ttfamily\ulcorner\,\textup{{#2}}\,\lrcorner}} +} +\newcommand{\link}[2]{%% + {\begin{scriptsize}\color{black}\urlstyle{tt}\href{#1} + {\;\ulcorner\,{#2}\,\lrcorner}\end{scriptsize}} +} \newcommand{\objCodeBlock}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} -\newcommand{\objCodeOpen}{\normaltext\raggedright\small\ttfamily\texbackslash -\begin{lstlisting} +\newcommand{\objCodeOpen}{%% + \normaltext\raggedright\small\ttfamily\texbackslash + \begin{lstlisting} } -\newcommand{\objCodeClose}{ -\end{lstlisting} +\newcommand{\objCodeClose}{%% + \end{lstlisting} } \newcommand{\ocn}[1]{%% \setlength{\parindent}{0em} @@ -1874,51 +1900,36 @@ $\txtbullet$\hspace{\enspace} \hspace{-0.5ex}{\marginpar{\begin{tiny}\hspace{0em}\hypertarget{#1}{#1}\end{tiny}}} \fi } -\newcommand{\ocnhold}[1]{ -\begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}} +\newcommand{\ocnhold}[1]{%% + \begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}} } \newcommand{\objCodeBlockHold}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} -\definecolor{listinggray}{gray}{0.9} -\definecolor{lbcolor}{rgb}{0.9,0.9,0.9} -\lstset{ - backgroundcolor=\color{lbcolor}, - tabsize=4, - rulecolor=, - language=, - basicstyle={\ttfamily\scriptsize}, - upquote=true, - columns=fixed, - showstringspaces=false, - extendedchars=true, - breaklines=true, - prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}}, - frame=single, - showtabs=false, - showspaces=false, - showstringspaces=false, - identifierstyle=\ttfamily, - keywordstyle=\color[rgb]{0,0,1}, - commentstyle=\color[rgb]{0.133,0.545,0.133}, - stringstyle=\color[rgb]{0.627,0.126,0.941}, -} -\newcommand{\objTableOpen}[1]{ -\setlength{\LTleft}{0pt} -\setlength{\LTright}{\fill} -\begin{tiny} -\begin{longtable}{#1} +\newcommand{\objTableOpen}[1]{%% + \setlength{\LTleft}{0pt} + \setlength{\LTright}{\fill} + \begin{tiny} + \begin{longtable}{#1} } -\newcommand{\objTableClose}{ -\end{longtable} -\end{tiny} +\newcommand{\objTableClose}{%% + \end{longtable} + \end{tiny} } #+END_SRC %%\chardef\asterisk="2A %%\newcommand{\hardspace}{\hspace{.5em}} +***** latex remove blank first page BUG FIX can REMOVE UNUSED + +#+NAME: FmtTxtSet_head_tex_bug_remove_blank_first_page +#+BEGIN_SRC latex +\usepackage{atbegshi} %% http://ctan.org/pkg/atbegshi %% (BUG tmp FIX deal with problem, remove first page which is blank) +\AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}} %% (BUG tmp FIX deal with problem, remove first page which is blank) +#+END_SRC + **** latex head format inclusions -#+NAME: output_latex_head_a_format_string_variables +#+NAME: FmtTxtClose_head_a_format_string_variables #+BEGIN_SRC d ┃", doc_matters.opt.action.debug_do_latex ? "" : doc_matters.generator_program.name_and_version.strip, @@ -1942,7 +1953,7 @@ $\txtbullet$\hspace{\enspace} **** latex head return -#+NAME: output_latex_head_close +#+NAME: MethodClose_head_close #+BEGIN_SRC d return _latex_head.strip; } @@ -1951,7 +1962,7 @@ $\txtbullet$\hspace{\enspace} *** ↻ latex body :content:body: **** latex body function -#+NAME: output_latex_body_function +#+NAME: MethodOpen_body_function #+BEGIN_SRC d string latex_body(D,M)( const D doc_abstraction, @@ -1965,7 +1976,7 @@ string latex_body(D,M)( **** ↻ loop open -#+NAME: output_latex_body_foreach_doc_part +#+NAME: MethodLoopOpen_body_foreach_doc_part #+BEGIN_SRC d foreach (part; doc_matters.has.keys_seq.latex) { foreach (obj; doc_abstraction[part]) { @@ -1975,7 +1986,7 @@ foreach (part; doc_matters.has.keys_seq.latex) { **** ↻ within loop ***** frontmatter -#+NAME: output_latex_body_for_doc_frontmatter +#+NAME: CasePart_body_for_doc_frontmatter #+BEGIN_SRC d case "frontmatter": assert(part == "head" || "toc"); _txt = obj.text @@ -2002,7 +2013,7 @@ case "frontmatter": assert(part == "head" || "toc"); ***** body -#+NAME: output_latex_body_for_doc_body +#+NAME: CasePart_body_for_doc_body #+BEGIN_SRC d case "body": assert(part == "body" || "head"); // surprise _txt = obj.text @@ -2060,7 +2071,7 @@ case "body": assert(part == "body" || "head"); // surprise ***** backmatter -#+NAME: output_latex_body_for_doc_backmatter +#+NAME: CasePart_body_for_doc_backmatter #+BEGIN_SRC d case "backmatter": assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); @@ -2120,7 +2131,7 @@ case "backmatter": ***** after -#+NAME: output_latex_body_for_doc_default +#+NAME: CasePart_body_for_doc_default #+BEGIN_SRC d case "comment": break; @@ -2145,7 +2156,7 @@ if (_multicolumns) { **** latex body return -#+NAME: output_latex_body_function_return +#+NAME: MethodClose_body_function_return #+BEGIN_SRC d return _latex_body; } @@ -2154,7 +2165,7 @@ if (_multicolumns) { *** latex tail :tail: **** latex tail function -#+NAME: output_latex_tail_function +#+NAME: MethodOpen_tail_function #+BEGIN_SRC d string latex_tail(M)( M doc_matters, @@ -2164,7 +2175,7 @@ string latex_tail(M)( **** latex tail starts -#+NAME: output_latex_tail_format_string +#+NAME: FmtTxtOpen_tail_format_string #+BEGIN_SRC d string _latex_tail = format(q"┃ #+END_SRC @@ -2173,7 +2184,7 @@ string _latex_tail = format(q"┃ ***** latex document end -#+NAME: output_latex_tail_format_string_tex +#+NAME: FmtTxtSet_tail_format_string_tex #+BEGIN_SRC latex \end{document} @@ -2181,7 +2192,7 @@ string _latex_tail = format(q"┃ **** latex tail format inclusions -#+NAME: output_latex_tail_format_string_close +#+NAME: FmtTxtClose_tail_format_string #+BEGIN_SRC d ┃", // doc_matters.conf_make_meta.meta.title_full, @@ -2191,7 +2202,7 @@ string _latex_tail = format(q"┃ **** latex tail return -#+NAME: output_latex_tail_function_return +#+NAME: MethodClose_tail_function_return #+BEGIN_SRC d return _latex_tail; } -- cgit v1.2.3