aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2022-03-02 16:26:51 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2022-03-05 10:33:48 -0500
commite19cbce11d980238daa8f77b16ca0c7ec6c130ee (patch)
treea5c8d20337e837d48f01bcfbc9dc2acb5fecb1e3
parentlatex \newcommand: \ocn for ocn with margin (diff)
latex, urls
-rw-r--r--org/out_latex.org87
-rw-r--r--src/doc_reform/io_out/latex.d83
2 files changed, 96 insertions, 74 deletions
diff --git a/org/out_latex.org b/org/out_latex.org
index 807010d..de73ab6 100644
--- a/org/out_latex.org
+++ b/org/out_latex.org
@@ -93,10 +93,8 @@ template outputLaTeX() {
<<output_latex_head_tex_set_columns>>
<<output_latex_head_tex_set_usepackages_languages_and_font>>
<<output_latex_head_tex_set_usepackages_1>>
-<<output_latex_head_tex_set_usepackages_color>>
<<output_latex_head_tex_set_metadata>>
<<output_latex_head_tex_set_colors>>
-<<output_latex_head_tex_set_url>>
<<output_latex_head_tex_set_usepackage_misc>>
<<output_latex_head_tex_set_indent_bullet_list>>
<<output_latex_head_tex_set_part_section_subsection_paragraph_subparagraph>>
@@ -542,11 +540,13 @@ _txt = _txt
m[1] ~ "┤" ~ to!string((obj.stow.link[m[2].to!ulong])).encode ~ "├"
)(_txt, rgx.inline_link_number_only);
_txt = replaceAll!(m =>
- ((m[1] == m[2]) && (m[2].match(rgx.uri)))
- ? format(q"┃\begin{scriptsize}\lefthalfcap\url{%s}\righthalfcup\end{scriptsize}┃", _check_link(m[1]))
- : (m[2].match(rgx.uri)) // ERROR
- ? format(q"┃%s\href{%s}%s{%s}┃", "\\\\\n", _check_link(m[2]), "\n", _if_images(m[1]))
- : format(q"┃\hyperlink{%s}{%s}┃", _check_link(m[2]), _if_images(m[1]))
+ ((m[1] == m[2]) && (m[2].match(rgx.uri))) // url link (regular link with url)
+ ? format(q"┃\linkurl{%s}{%s}┃", _check_link(m[1]), (_check_link(m[1])).sp_char_esc_txt)
+ : ((m[2].match(rgx.uri)) && (m[1].match(rgx.inline_image_info))) // linked image
+ ? format(q"┃%s\href{%s}%s{%s}┃", "\\\\\n", _check_link(m[2]), "\n", _if_images(m[1])) // markup for images
+ : (m[2].match(rgx.uri)) // not linked image
+ ? format(q"┃%s\linktext{%s}{%s}┃", "\\\\\n", _check_link(m[2]), m[1]) // regular link with text
+ : format(q"┃\hyperlink{%s}{%s}┃", _check_link(m[2]), _if_images(m[1])) // internal links, like book index
)(_txt, rgx.inline_link);
}
}
@@ -1153,7 +1153,7 @@ margins.portrait = format(q"┃
#+NAME: output_latex_head_tex_papermargins_portrait_set
#+BEGIN_SRC latex
\setlength{\oddsidemargin}{0mm} \setlength{\evensidemargin}{0mm}
-\setlength{\topmargin}{-12pt} \setlength{\headheight}{12pt}
+\setlength{\topmargin}{-0.5pt} \setlength{\headheight}{14.5pt}
\setlength{\headsep}{35pt}
#+END_SRC
@@ -1173,7 +1173,7 @@ margins.landscape = format(q"┃
#+NAME: output_latex_head_tex_papermargins_landscape_set
#+BEGIN_SRC latex
\setlength{\oddsidemargin}{6mm} \setlength{\evensidemargin}{6mm}
-\setlength{\topmargin}{-12mm} \setlength{\headheight}{12pt}
+\setlength{\topmargin}{-0.5pt} \setlength{\headheight}{14.5pt}
\setlength{\headsep}{20pt}
#+END_SRC
@@ -1241,11 +1241,11 @@ links.mono = format(q"┃
#+NAME: output_latex_head_tex_colorlinks_mono_set
#+BEGIN_SRC latex
-\usepackage[xetex,
colorlinks=true,
- urlcolor=myblack,
- filecolor=myblack,
- linkcolor=myblack,
+ urlcolor=black,
+ filecolor=black,
+ linkcolor=black,
+ citecolor=black,
#+END_SRC
#+NAME: output_latex_head_tex_colorlinks_mono_close
@@ -1263,11 +1263,11 @@ links.color = format(q"┃
#+NAME: output_latex_head_tex_colorlinks_color_set
#+BEGIN_SRC latex
-\usepackage[xetex,
colorlinks=true,
urlcolor=myblue, %% \href{...}{...} external url
filecolor=mygreen, %% \href{...} local file
linkcolor=myred, %% \href{...} and \pageref{...}
+ citecolor=black,
#+END_SRC
#+NAME: output_latex_head_tex_colorlinks_color_close
@@ -1459,37 +1459,42 @@ string _latex_head = format(q"┃%%%% spine LaTeX output
#+BEGIN_SRC latex
\usepackage{alltt}
\usepackage{thumbpdf}
+\usepackage{hyperref}
+\hypersetup{
#+END_SRC
-***** color links: no = mono | yes = color
-
-#+NAME: output_latex_head_tex_set_usepackages_color
-#+BEGIN_SRC latex
-%s
-#+END_SRC
-
-***** metadata
+***** hyperref metadata
#+NAME: output_latex_head_tex_set_metadata
#+BEGIN_SRC latex
pdftitle={%s},
pdfauthor={%s},
pdfsubject={%s},
- pdfkeywords={},
- pageanchor=true,
- plainpages=true,
- pdfpagelabels=true,
- pagebackref,
- bookmarks=true,
- bookmarksopen=true,
+ pdfkeywords={}, %% keywords list {} {} {},
+ pdftoolbar=true,
pdfmenubar=true,
pdfpagemode=UseOutline,
- pdffitwindow=true,
pdfwindowui=true,
- plainpages=false,
- pdfstartview=FitH
-]
-{hyperref}
+ 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
+ pdfpagelabels=true,
+ pageanchor=true,
+ pagebackref=true,
+ plainpages=false, %% was true
+ bookmarks=true,
+ bookmarksopen=false,
+ %% colorlinks=true,
+ %% urlcolor=black,
+ %% filecolor=black,
+ %% linkcolor=black,
+ %% citecolor=black,
+%s %% links_mono_or_color_set
+ pdfpublisher={}, %% document publisher
+ pdfcreator={}, %% document creator
+ pdfproducer={}, %% document producer
+}
+\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
#+END_SRC
%% pdfusetitle=true,
@@ -1516,12 +1521,6 @@ string _latex_head = format(q"┃%%%% spine LaTeX output
***** latex head
-#+NAME: output_latex_head_tex_set_url
-#+BEGIN_SRC latex
-\usepackage{url}
-\urlstyle{sf}
-#+END_SRC
-
%%\usepackage{breakurl}
***** latex head
@@ -1656,6 +1655,12 @@ string _latex_head = format(q"┃%%%% spine LaTeX output
\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{\ocn}[1]{
\begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}}
}
@@ -1703,10 +1708,10 @@ string _latex_head = format(q"┃%%%% spine LaTeX output
multicol.portrait.strip,
lang.codes[doc_matters.src.language]["xlp"],
"english",
- links_mono_or_color_set,
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,
+ links_mono_or_color_set,
lang.codes[doc_matters.src.language]["xlp"],
_footer(doc_matters),
);
diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d
index d87a938..48afecb 100644
--- a/src/doc_reform/io_out/latex.d
+++ b/src/doc_reform/io_out/latex.d
@@ -343,11 +343,13 @@ template outputLaTeX() {
m[1] ~ "┤" ~ to!string((obj.stow.link[m[2].to!ulong])).encode ~ "├"
)(_txt, rgx.inline_link_number_only);
_txt = replaceAll!(m =>
- ((m[1] == m[2]) && (m[2].match(rgx.uri)))
- ? format(q"┃\begin{scriptsize}\lefthalfcap\url{%s}\righthalfcup\end{scriptsize}┃", _check_link(m[1]))
- : (m[2].match(rgx.uri)) // ERROR
- ? format(q"┃%s\href{%s}%s{%s}┃", "\\\\\n", _check_link(m[2]), "\n", _if_images(m[1]))
- : format(q"┃\hyperlink{%s}{%s}┃", _check_link(m[2]), _if_images(m[1]))
+ ((m[1] == m[2]) && (m[2].match(rgx.uri))) // url link (regular link with url)
+ ? format(q"┃\linkurl{%s}{%s}┃", _check_link(m[1]), (_check_link(m[1])).sp_char_esc_txt)
+ : ((m[2].match(rgx.uri)) && (m[1].match(rgx.inline_image_info))) // linked image
+ ? format(q"┃%s\href{%s}%s{%s}┃", "\\\\\n", _check_link(m[2]), "\n", _if_images(m[1])) // markup for images
+ : (m[2].match(rgx.uri)) // not linked image
+ ? format(q"┃%s\linktext{%s}{%s}┃", "\\\\\n", _check_link(m[2]), m[1]) // regular link with text
+ : format(q"┃\hyperlink{%s}{%s}┃", _check_link(m[2]), _if_images(m[1])) // internal links, like book index
)(_txt, rgx.inline_link);
}
}
@@ -828,13 +830,13 @@ string table(O,M)(
auto margins = paperMargins();
margins.portrait = format(q"┃
\setlength{\oddsidemargin}{0mm} \setlength{\evensidemargin}{0mm}
-\setlength{\topmargin}{-12pt} \setlength{\headheight}{12pt}
+\setlength{\topmargin}{-0.5pt} \setlength{\headheight}{14.5pt}
\setlength{\headsep}{35pt}
┃",
);
margins.landscape = format(q"┃
\setlength{\oddsidemargin}{6mm} \setlength{\evensidemargin}{6mm}
-\setlength{\topmargin}{-12mm} \setlength{\headheight}{12pt}
+\setlength{\topmargin}{-0.5pt} \setlength{\headheight}{14.5pt}
\setlength{\headsep}{20pt}
┃",
);
@@ -854,19 +856,19 @@ string table(O,M)(
}
auto links = colorLinks();
links.mono = format(q"┃
-\usepackage[xetex,
- colorlinks=true,
- urlcolor=myblack,
- filecolor=myblack,
- linkcolor=myblack,
+colorlinks=true,
+urlcolor=black,
+filecolor=black,
+linkcolor=black,
+citecolor=black,
┃",
);
links.color = format(q"┃
-\usepackage[xetex,
- colorlinks=true,
- urlcolor=myblue, %% \href{...}{...} external url
- filecolor=mygreen, %% \href{...} local file
- linkcolor=myred, %% \href{...} and \pageref{...}
+colorlinks=true,
+urlcolor=myblue, %% \href{...}{...} external url
+filecolor=mygreen, %% \href{...} local file
+linkcolor=myred, %% \href{...} and \pageref{...}
+citecolor=black,
┃",
);
string set_paper(P)(P paper_set,) {
@@ -943,33 +945,42 @@ string table(O,M)(
\setmonofont[Scale=0.85]{Liberation Mono}
\usepackage{alltt}
\usepackage{thumbpdf}
-%s
+\usepackage{hyperref}
+\hypersetup{
pdftitle={%s},
pdfauthor={%s},
pdfsubject={%s},
- pdfkeywords={},
- pageanchor=true,
- plainpages=true,
- pdfpagelabels=true,
- pagebackref,
- bookmarks=true,
- bookmarksopen=true,
+ pdfkeywords={}, %% keywords list {} {} {},
+ pdftoolbar=true,
pdfmenubar=true,
pdfpagemode=UseOutline,
- pdffitwindow=true,
pdfwindowui=true,
- plainpages=false,
- pdfstartview=FitH
-]
-{hyperref}
+ 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
+ pdfpagelabels=true,
+ pageanchor=true,
+ pagebackref=true,
+ plainpages=false, %% was true
+ bookmarks=true,
+ bookmarksopen=false,
+ %% colorlinks=true,
+ %% urlcolor=black,
+ %% filecolor=black,
+ %% linkcolor=black,
+ %% citecolor=black,
+%s %% links_mono_or_color_set
+ pdfpublisher={}, %% document publisher
+ pdfcreator={}, %% document creator
+ pdfproducer={}, %% document producer
+}
+\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\usepackage[usenames]{color}
\definecolor{myblack}{rgb}{0,0,0}
\definecolor{myred}{rgb}{0.75,0,0}
\definecolor{mygreen}{rgb}{0,0.5,0}
\definecolor{myblue}{rgb}{0,0,0.5}
\definecolor{mywhite}{rgb}{1,1,1}
-\usepackage{url}
-\urlstyle{sf}
\usepackage{textcomp}
\usepackage[parfill]{parskip}
\usepackage[normalem]{ulem}
@@ -1076,6 +1087,12 @@ string table(O,M)(
\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{\ocn}[1]{
\begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}}
}
@@ -1114,10 +1131,10 @@ string table(O,M)(
multicol.portrait.strip,
lang.codes[doc_matters.src.language]["xlp"],
"english",
- links_mono_or_color_set,
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,
+ links_mono_or_color_set,
lang.codes[doc_matters.src.language]["xlp"],
_footer(doc_matters),
);