From 61409898f0cbd255c1019e1f988de1a978830fe9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 19 Jul 2019 12:04:10 -0400 Subject: texpdf, footer & language setting --- org/output_latex.org | 69 ++++++++++++++++++++++++++++++++++--------- src/doc_reform/output/latex.d | 47 +++++++++++++++++++++++++---- 2 files changed, 96 insertions(+), 20 deletions(-) diff --git a/org/output_latex.org b/org/output_latex.org index 4c3cf5f..eb50c46 100644 --- a/org/output_latex.org +++ b/org/output_latex.org @@ -26,15 +26,17 @@ template outputLaTeX() { mixin InternalMarkup; // watch mixin DocReformOutputRgxInit; auto rgx = Rgx(); + mixin DocReformLanguageCodes; + auto lang = Lang(); <> <> <> - <> + <> <> - <> - <> + <> + <> <> - <> + <> <> <> <> @@ -539,7 +541,8 @@ string bullets_and_indentation(O)( ) { _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin).to!string; _hang = (((obj.attrib.indent_hang - obj.attrib.indent_base) * _indent_increment)).to!string; - _txt = format(q"┃\begin{ParagraphHang}{%smm}{%smm}%s \end{ParagraphHang}┃", + _tex_para = q"┃\begin{ParagraphHang}{%smm}{%smm}%s \end{ParagraphHang}┃"; + _txt = format(_tex_para, _indent, _hang, _txt.footnotes ).strip; @@ -962,9 +965,44 @@ string latex_head(M)( auto paper = paperType(); #+END_SRC +****** footer + +#+name: output_latex_head +#+BEGIN_SRC d + string _footer(M)(M doc_matters) { + writeln("footer: ", doc_matters.conf_make_meta.make.footer); + string _ft = "\\lfoot[\\textrm{\\thepage}]"; + string _ft_1 = format(q"┃{\tiny \href{%s}{%s}}┃", "http://sisudoc.org", "SiSU",); + string _ft_2 = format(q"┃ +\cfoot{\href{%s}{%s}}┃", "http://git.sisudoc.org", "git",); + if (doc_matters.conf_make_meta.make.footer.length > 0) { + if (doc_matters.conf_make_meta.make.footer.length > 0) { + if (doc_matters.conf_make_meta.make.footer[0].matchAll(rgx.inline_link)) { + _ft ~= doc_matters.conf_make_meta.make.footer[0] + .replace(rgx.inline_link, "{\\tiny \\href{$2}{$1}}"); + } else { + _ft ~= _ft_1; + } + } + if (doc_matters.conf_make_meta.make.footer.length > 1) { + if (doc_matters.conf_make_meta.make.footer[1].matchAll(rgx.inline_link)) { + _ft ~= doc_matters.conf_make_meta.make.footer[1] + .replace(rgx.inline_link, "\n\\cfoot{\\href{$2}{$1}}"); + } else { + _ft ~= _ft_2; + } + } + } else { + _ft ~= _ft_1; + _ft ~= _ft_2; + } + return _ft; + } +#+END_SRC + ****** a4, portrait -#+name: output_latex_head_1 +#+name: output_latex_head_1_format_string #+BEGIN_SRC d paper.a4_portrait = format(q"┃ #+END_SRC @@ -1177,7 +1215,7 @@ string latex_head(M)( linkcolor=myred, %% \href{...} and \pageref{...} #+END_SRC -#+name: output_latex_head_1_close +#+name: output_latex_head_1_format_string_variables #+BEGIN_SRC d ┃", ); @@ -1185,7 +1223,7 @@ string latex_head(M)( **** latex head starts -#+name: output_latex_head_0 +#+name: output_latex_head_0_format_string #+BEGIN_SRC d string _latex_head = format(q"┃%%%% DocReform LaTeX output #+END_SRC @@ -1243,8 +1281,8 @@ string latex_head(M)( #+name: output_latex_head_0_tex #+BEGIN_SRC latex \usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} -\setmainlanguage{english} -\setotherlanguage{} +\setmainlanguage{%s} +\setotherlanguage{%s} \setmainfont{Liberation Sans} \setmonofont[Scale=0.85]{Liberation Mono} #+END_SRC @@ -1427,12 +1465,11 @@ string latex_head(M)( #+name: output_latex_head_0_tex #+BEGIN_SRC latex -\selectlanguage{english} +\selectlanguage{%s} \lhead[ ]{ } \chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark } \rhead[ ]{ } -\lfoot[\textrm{\thepage}]{\tiny \href{http://sisudoc.org}{SiSU}} -\cfoot{\href{http://git.sisudoc.org}{git}} +%s \rfoot[\tiny \href{}{}]{\textrm{\thepage}} \tolerance=300 \clubpenalty=300 @@ -1487,17 +1524,21 @@ string latex_head(M)( **** latex head format inclusions -#+name: output_latex_head_0_close +#+name: output_latex_head_0_format_string_variables #+BEGIN_SRC d ┃", doc_matters.opt.action.debug_do ? "" : doc_matters.generator_program.name_and_version.strip, paper.a4_portrait.strip, margins.portrait.strip, multicol.portrait.strip, + lang.codes[doc_matters.src.language]["xlp"], + "english", links.mono.strip, // links.color.strip, doc_matters.conf_make_meta.meta.title_full.strip, doc_matters.conf_make_meta.meta.creator_author.strip, doc_matters.conf_make_meta.meta.classify_subject.strip, + lang.codes[doc_matters.src.language]["xlp"], + _footer(doc_matters), ); #+END_SRC diff --git a/src/doc_reform/output/latex.d b/src/doc_reform/output/latex.d index 88cc75c..674d6d3 100644 --- a/src/doc_reform/output/latex.d +++ b/src/doc_reform/output/latex.d @@ -10,6 +10,8 @@ template outputLaTeX() { mixin InternalMarkup; // watch mixin DocReformOutputRgxInit; auto rgx = Rgx(); + mixin DocReformLanguageCodes; + auto lang = Lang(); auto paper() { struct PaperType { auto a4() { @@ -668,7 +670,8 @@ string table(O,M)( ) { _indent = ((obj.attrib.indent_base * _indent_increment) + _paper_margin).to!string; _hang = (((obj.attrib.indent_hang - obj.attrib.indent_base) * _indent_increment)).to!string; - _txt = format(q"┃\begin{ParagraphHang}{%smm}{%smm}%s \end{ParagraphHang}┃", + _tex_para = q"┃\begin{ParagraphHang}{%smm}{%smm}%s \end{ParagraphHang}┃"; + _txt = format(_tex_para, _indent, _hang, _txt.footnotes ).strip; @@ -685,6 +688,35 @@ string table(O,M)( string us_letter_landscape; } auto paper = paperType(); + string _footer(M)(M doc_matters) { + writeln("footer: ", doc_matters.conf_make_meta.make.footer); + string _ft = "\\lfoot[\\textrm{\\thepage}]"; + string _ft_1 = format(q"┃{\tiny \href{%s}{%s}}┃", "http://sisudoc.org", "SiSU",); + string _ft_2 = format(q"┃ + \cfoot{\href{%s}{%s}}┃", "http://git.sisudoc.org", "git",); + if (doc_matters.conf_make_meta.make.footer.length > 0) { + if (doc_matters.conf_make_meta.make.footer.length > 0) { + if (doc_matters.conf_make_meta.make.footer[0].matchAll(rgx.inline_link)) { + _ft ~= doc_matters.conf_make_meta.make.footer[0] + .replace(rgx.inline_link, "{\\tiny \\href{$2}{$1}}"); + } else { + _ft ~= _ft_1; + } + } + if (doc_matters.conf_make_meta.make.footer.length > 1) { + if (doc_matters.conf_make_meta.make.footer[1].matchAll(rgx.inline_link)) { + _ft ~= doc_matters.conf_make_meta.make.footer[1] + .replace(rgx.inline_link, "\n\\cfoot{\\href{$2}{$1}}"); + } else { + _ft ~= _ft_2; + } + } + } else { + _ft ~= _ft_1; + _ft ~= _ft_2; + } + return _ft; + } paper.a4_portrait = format(q"┃ \documentclass[12pt,a4paper,titlepage]{scrartcl} \setlength{\textheight}{228mm} \setlength{\textwidth}{160mm} @@ -765,8 +797,8 @@ string table(O,M)( \setlength{\marginparwidth}{8mm} %s \usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} -\setmainlanguage{english} -\setotherlanguage{} +\setmainlanguage{%s} +\setotherlanguage{%s} \setmainfont{Liberation Sans} \setmonofont[Scale=0.85]{Liberation Mono} \usepackage{alltt} @@ -876,12 +908,11 @@ string table(O,M)( {subparagraph}%%{6}%%{-2mm}%% {-\baselineskip}{0.5\baselineskip}%% {\normalfont\normalsize\itshape\raggedright}} -\selectlanguage{english} +\selectlanguage{%s} \lhead[ ]{ } \chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark } \rhead[ ]{ } -\lfoot[\textrm{\thepage}]{\tiny \href{http://sisudoc.org}{SiSU}} -\cfoot{\href{http://git.sisudoc.org}{git}} +%s \rfoot[\tiny \href{}{}]{\textrm{\thepage}} \tolerance=300 \clubpenalty=300 @@ -934,10 +965,14 @@ string table(O,M)( paper.a4_portrait.strip, margins.portrait.strip, multicol.portrait.strip, + lang.codes[doc_matters.src.language]["xlp"], + "english", links.mono.strip, // links.color.strip, doc_matters.conf_make_meta.meta.title_full.strip, doc_matters.conf_make_meta.meta.creator_author.strip, doc_matters.conf_make_meta.meta.classify_subject.strip, + lang.codes[doc_matters.src.language]["xlp"], + _footer(doc_matters), ); return _latex_head.strip; } -- cgit v1.2.3