From 0c693b23c4ff8f98a151884a24f150a5ff746dd4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 16 Oct 2020 19:16:18 -0400 Subject: org mode, unique code-block names & adjust headers - avoid org-mode undefined behavior, provide unique code-block names --- org/out_latex.org | 238 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 151 insertions(+), 87 deletions(-) (limited to 'org/out_latex.org') diff --git a/org/out_latex.org b/org/out_latex.org index c9610c3..ff56f47 100644 --- a/org/out_latex.org +++ b/org/out_latex.org @@ -7,6 +7,7 @@ #+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah #+LANGUAGE: en #+STARTUP: content hideblocks hidestars noindent entitiespretty +#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t #+PROPERTY: header-args :exports code #+PROPERTY: header-args+ :noweb yes #+PROPERTY: header-args+ :eval no @@ -29,26 +30,89 @@ template outputLaTeX() { static auto rgx = RgxO(); mixin spineLanguageCodes; auto lang = Lang(); - <> -<> - <> -<> - <> - <> -<> - <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> +<> +<> +<> +<> +<> +<> +<> + <> + <> + <> + <> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> + <> + <> + <> + <> + <> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> + <> <> - <> - <> + <> + <> + <> + <> + <> + <> + <> + <> + <> <> - <> - <> + <> + <> + <> + <> } #+END_SRC ** write latex output :latex:out: -#+NAME: output_latex +#+NAME: output_latex_0 #+BEGIN_SRC d void writeOutputLaTeX(T,M)( const T latex_content, @@ -90,7 +154,7 @@ void writeOutputLaTeX(T,M)( ** latex output hub [#A] :latex:pdf:out: -#+NAME: output_latex +#+NAME: output_latex_1 #+BEGIN_SRC d void outputLaTeX(D,M)( const D doc_abstraction, @@ -128,7 +192,7 @@ import doc_reform.io_out; ** shared *** paper dimensions (struct) -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_0 #+BEGIN_SRC d auto paper() { struct PaperType { @@ -295,7 +359,7 @@ import doc_reform.io_out; *** latex \escape special characters **** general -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_1 #+BEGIN_SRC d @safe string sp_char_esc(O)( string _txt, @@ -324,7 +388,7 @@ import doc_reform.io_out; } #+END_SRC -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_2 #+BEGIN_SRC d @safe string sp_char_esc_txt()( string _txt, @@ -366,7 +430,7 @@ import doc_reform.io_out; - bold, italics, underscore, strikethrough -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_3 #+BEGIN_SRC d @safe string fontface()( string _txt, @@ -389,7 +453,7 @@ _txt = _txt **** spaces ***** leading hardspace -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_4 #+BEGIN_SRC d @safe string leading_hardspaces()( string _txt, @@ -406,7 +470,7 @@ _txt = _txt ***** nbsp character -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_5 #+BEGIN_SRC d @safe string nbsp_char()(string _txt) { if (_txt.match(rgx.nbsp_char)) { @@ -418,7 +482,7 @@ _txt = _txt ***** remove nbsp character -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_6 #+BEGIN_SRC d @safe string nbsp_char_to_space()(string _txt) { if (_txt.match(rgx.nbsp_char)) { @@ -431,7 +495,7 @@ _txt = _txt **** links and images ***** links / urls -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_7 #+BEGIN_SRC d @safe string links_and_images(O,M)( string _txt, @@ -483,7 +547,7 @@ _txt = _txt *** footnotes **** footnotes -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_8 #+BEGIN_SRC d @safe string footnotes()( string _txt, @@ -504,7 +568,7 @@ _txt = _txt **** footnote remove -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_9 #+BEGIN_SRC d @safe string remove_footnotes()( string _txt, @@ -519,7 +583,7 @@ _txt = _txt *** para **** para -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_10 #+BEGIN_SRC d @safe string para(O)( string _txt, @@ -540,7 +604,7 @@ _txt = _txt **** bookindex para -#+NAME: output_latex_shared +#+NAME: output_latex_shared_a_11 #+BEGIN_SRC d @safe string bookindex(O)( string _txt, @@ -561,7 +625,7 @@ _txt = _txt *** bullets & indentation -#+NAME: output_latex_head +#+NAME: output_latex_head_0 #+BEGIN_SRC d @safe string bullets_and_indentation(O)( string _txt, @@ -606,7 +670,7 @@ _txt = _txt *** heading -#+NAME: output_latex_shared_0 +#+NAME: output_latex_shared_b_0 #+BEGIN_SRC d @safe string heading(O,M)( string _txt, @@ -780,7 +844,7 @@ _txt = _txt - (hardspace not honored) clear hardspace marker -#+NAME: output_latex_shared_0 +#+NAME: output_latex_shared_b_1 #+BEGIN_SRC d string group(O,M)( string _txt, @@ -808,7 +872,7 @@ string group(O,M)( - (hardspace honored) \hardspace -#+NAME: output_latex_shared_0 +#+NAME: output_latex_shared_b_2 #+BEGIN_SRC d string block(O,M)( string _txt, @@ -840,7 +904,7 @@ string block(O,M)( - (hardspace honored) \hardspace -#+NAME: output_latex_shared_0 +#+NAME: output_latex_shared_b_3 #+BEGIN_SRC d string verse(O,M)( string _txt, @@ -872,7 +936,7 @@ string verse(O,M)( - (hardspace honored) \begin{lstlisting} clear hardspace marker -#+NAME: output_latex_shared_0 +#+NAME: output_latex_shared_b_4 #+BEGIN_SRC d string codeblock(O,M)( string _txt, @@ -904,7 +968,7 @@ string codeblock(O,M)( ***** tablarize -#+NAME: output_latex_shared_0 +#+NAME: output_latex_shared_b_5 #+BEGIN_SRC d auto tablarize(O)( string _txt, @@ -943,7 +1007,7 @@ auto tablarize(O)( ***** table -#+NAME: output_latex_shared_0 +#+NAME: output_latex_shared_b_6 #+BEGIN_SRC d string table(O,M)( string _txt, @@ -1003,7 +1067,7 @@ string table(O,M)( *** latex head :head: **** latex head function -#+NAME: output_latex_head +#+NAME: output_latex_head_1 #+BEGIN_SRC d string latex_head(M)( M doc_matters, @@ -1015,7 +1079,7 @@ string latex_head(M)( ***** paper type dimensions ****** struct -#+NAME: output_latex_head +#+NAME: output_latex_head_2 #+BEGIN_SRC d struct paperTypeLatex { string a4_portrait; @@ -1034,7 +1098,7 @@ string latex_head(M)( ****** footer -#+NAME: output_latex_head +#+NAME: output_latex_head_3 #+BEGIN_SRC d string _footer(M)(M doc_matters) { string _ft = "\\lfoot[\\textrm{\\thepage}]"; @@ -1069,7 +1133,7 @@ string latex_head(M)( ***** paper margins ****** struct -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_0 #+BEGIN_SRC d struct paperMargins { string portrait; @@ -1080,19 +1144,19 @@ string latex_head(M)( ****** portrait -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_1 #+BEGIN_SRC d margins.portrait = format(q"┃ #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_2 #+BEGIN_SRC latex \setlength{\oddsidemargin}{0mm} \setlength{\evensidemargin}{0mm} \setlength{\topmargin}{-12pt} \setlength{\headheight}{12pt} \setlength{\headsep}{35pt} #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_3 #+BEGIN_SRC d ┃", ); @@ -1100,19 +1164,19 @@ string latex_head(M)( ****** landscape -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_4 #+BEGIN_SRC d margins.landscape = format(q"┃ #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_5 #+BEGIN_SRC latex \setlength{\oddsidemargin}{6mm} \setlength{\evensidemargin}{6mm} \setlength{\topmargin}{-12mm} \setlength{\headheight}{12pt} \setlength{\headsep}{20pt} #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_6 #+BEGIN_SRC d ┃", ); @@ -1121,7 +1185,7 @@ string latex_head(M)( ***** multicol ****** struct -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_7 #+BEGIN_SRC d struct columnsMulti { string portrait; @@ -1132,17 +1196,17 @@ string latex_head(M)( ****** portrait -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_8 #+BEGIN_SRC d multicol.portrait = format(q"┃ #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_9 #+BEGIN_SRC latex \usepackage{multicol} #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_10 #+BEGIN_SRC d ┃", ); @@ -1150,7 +1214,7 @@ string latex_head(M)( ****** landscape -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_11 #+BEGIN_SRC d multicol.landscape = ""; #+END_SRC @@ -1158,7 +1222,7 @@ string latex_head(M)( ***** color links ****** struct -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_12 #+BEGIN_SRC d struct colorLinks { string mono; @@ -1169,12 +1233,12 @@ string latex_head(M)( ****** mono -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_13 #+BEGIN_SRC d links.mono = format(q"┃ #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_14 #+BEGIN_SRC latex \usepackage[xetex, colorlinks=true, @@ -1183,7 +1247,7 @@ string latex_head(M)( linkcolor=myblack, #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_15 #+BEGIN_SRC d ┃", ); @@ -1191,12 +1255,12 @@ string latex_head(M)( ****** color -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_16 #+BEGIN_SRC d links.color = format(q"┃ #+END_SRC -#+NAME: output_latex_head_1_tex +#+NAME: output_latex_head_b_tex_17 #+BEGIN_SRC latex \usepackage[xetex, colorlinks=true, @@ -1205,7 +1269,7 @@ string latex_head(M)( linkcolor=myred, %% \href{...} and \pageref{...} #+END_SRC -#+NAME: output_latex_head_1_format_string_variables +#+NAME: output_latex_head_b_format_string_variables #+BEGIN_SRC d ┃", ); @@ -1215,7 +1279,7 @@ string latex_head(M)( ***** dimensions & orientation ****** set -#+NAME: output_latex_head_0_format_string +#+NAME: output_latex_head_format_string_0 #+BEGIN_SRC d string set_paper(P)(P paper_set,) { string paper_type_description; @@ -1246,7 +1310,7 @@ string latex_head(M)( ***** (a4, a5, b4, letter, legal) * (portrait & landscape) -#+NAME: output_latex_head_0_format_string +#+NAME: output_latex_head_format_string_1 #+BEGIN_SRC d string paper_size_orientation_latex; switch (paper_size_orientation) { @@ -1266,7 +1330,7 @@ string latex_head(M)( ***** set color links -#+NAME: output_latex_head_0_format_string +#+NAME: output_latex_head_format_string_2 #+BEGIN_SRC d string links_mono_or_color_set = links.mono.strip; if ( @@ -1284,14 +1348,14 @@ string latex_head(M)( ***** format latex head, open -#+NAME: output_latex_head_0_format_string +#+NAME: output_latex_head_format_string_3 #+BEGIN_SRC d string _latex_head = format(q"┃%%%% spine LaTeX output #+END_SRC ***** description comment -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_0 #+BEGIN_SRC latex %%%% Generated by: %s %%%% D version: %s @@ -1308,7 +1372,7 @@ string latex_head(M)( - paper_type_latex.us_letter_portrait - paper_type_latex.us_letter_landscape -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_1 #+BEGIN_SRC latex %s #+END_SRC @@ -1318,14 +1382,14 @@ string latex_head(M)( - margins.portrait - margins.landscape -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_2 #+BEGIN_SRC latex %s #+END_SRC ***** margin shared -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_3 #+BEGIN_SRC latex \setlength{\marginparsep}{4mm} \setlength{\marginparwidth}{8mm} @@ -1333,14 +1397,14 @@ string latex_head(M)( ***** multicol (portrait | landscape) -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_4 #+BEGIN_SRC latex %s #+END_SRC ***** language & font -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_5 #+BEGIN_SRC latex \usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} \setmainlanguage{%s} @@ -1354,7 +1418,7 @@ string latex_head(M)( ***** latex head -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_6 #+BEGIN_SRC latex \usepackage{alltt} \usepackage{thumbpdf} @@ -1362,14 +1426,14 @@ string latex_head(M)( ***** color links: no = mono | yes = color -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_7 #+BEGIN_SRC latex %s #+END_SRC ***** metadata -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_8 #+BEGIN_SRC latex pdftitle={%s}, pdfauthor={%s}, @@ -1403,7 +1467,7 @@ string latex_head(M)( ***** define colors -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_9 #+BEGIN_SRC latex \usepackage[usenames]{color} \definecolor{myblack}{rgb}{0,0,0} @@ -1415,7 +1479,7 @@ string latex_head(M)( ***** latex head -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_10 #+BEGIN_SRC latex \usepackage{url} \urlstyle{sf} @@ -1425,7 +1489,7 @@ string latex_head(M)( ***** latex head -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_11 #+BEGIN_SRC latex \usepackage{textcomp} \usepackage[parfill]{parskip} @@ -1447,7 +1511,7 @@ string latex_head(M)( ***** indent, bullet, list -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_12 #+BEGIN_SRC latex \usepackage[multiple,ragged]{footmisc} \setlength\footnotemargin{12pt} @@ -1491,7 +1555,7 @@ string latex_head(M)( ***** part, section, subsection, paragraph, subparagraph -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_13 #+BEGIN_SRC latex \usepackage{fancyhdr} \lhead{} @@ -1525,7 +1589,7 @@ string latex_head(M)( ***** latex head misc. including defined commands -#+NAME: output_latex_head_0_tex +#+NAME: output_latex_head_tex_14 #+BEGIN_SRC latex \selectlanguage{%s} \lhead[ ]{ } @@ -1586,7 +1650,7 @@ string latex_head(M)( **** latex head format inclusions -#+NAME: output_latex_head_0_format_string_variables +#+NAME: output_latex_head_a_format_string_variables #+BEGIN_SRC d ┃", doc_matters.opt.action.debug_do ? "" : doc_matters.generator_program.name_and_version.strip, @@ -1619,7 +1683,7 @@ string latex_head(M)( *** ↻ latex body :content:body: **** latex body function -#+NAME: output_latex_body +#+NAME: output_latex_body_0 #+BEGIN_SRC d string latex_body(D,M)( const D doc_abstraction, @@ -1633,7 +1697,7 @@ string latex_body(D,M)( **** ↻ loop open -#+NAME: output_latex_body +#+NAME: output_latex_body_1 #+BEGIN_SRC d foreach (part; doc_matters.has.keys_seq.latex) { foreach (obj; doc_abstraction[part]) { @@ -1643,7 +1707,7 @@ string latex_body(D,M)( **** ↻ within loop ***** frontmatter -#+NAME: output_latex_body +#+NAME: output_latex_body_2 #+BEGIN_SRC d case "frontmatter": assert(part == "head" || "toc"); _txt = obj.text @@ -1670,7 +1734,7 @@ string latex_body(D,M)( ***** body -#+NAME: output_latex_body +#+NAME: output_latex_body_3 #+BEGIN_SRC d case "body": assert(part == "body" || "head"); // surprise _txt = obj.text @@ -1732,7 +1796,7 @@ string latex_body(D,M)( ***** backmatter -#+NAME: output_latex_body +#+NAME: output_latex_body_4 #+BEGIN_SRC d case "backmatter": assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); @@ -1792,7 +1856,7 @@ string latex_body(D,M)( ***** after -#+NAME: output_latex_body +#+NAME: output_latex_body_5 #+BEGIN_SRC d case "comment": break; @@ -1817,7 +1881,7 @@ string latex_body(D,M)( **** latex body return -#+NAME: output_latex_body +#+NAME: output_latex_body_6 #+BEGIN_SRC d return _latex_body; } @@ -1826,7 +1890,7 @@ string latex_body(D,M)( *** latex tail :tail: **** latex tail function -#+NAME: output_latex_tail +#+NAME: output_latex_tail_0 #+BEGIN_SRC d string latex_tail(M)( M doc_matters, @@ -1836,7 +1900,7 @@ string latex_tail(M)( **** latex tail starts -#+NAME: output_latex_tail +#+NAME: output_latex_tail_1 #+BEGIN_SRC d string _latex_tail = format(q"┃ #+END_SRC @@ -1854,7 +1918,7 @@ string latex_tail(M)( **** latex tail format inclusions -#+NAME: output_latex_tail_close +#+NAME: output_latex_tail_close_0 #+BEGIN_SRC d ┃", // doc_matters.conf_make_meta.meta.title_full, @@ -1864,7 +1928,7 @@ string latex_tail(M)( **** latex tail return -#+NAME: output_latex_tail_close +#+NAME: output_latex_tail_close_1 #+BEGIN_SRC d return _latex_tail; } -- cgit v1.2.3