aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/io_out
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc_reform/io_out')
-rw-r--r--src/doc_reform/io_out/latex.d260
-rw-r--r--src/doc_reform/io_out/paths_output.d8
2 files changed, 191 insertions, 77 deletions
diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d
index 8ec144b..a021ee2 100644
--- a/src/doc_reform/io_out/latex.d
+++ b/src/doc_reform/io_out/latex.d
@@ -18,17 +18,27 @@ template outputLaTeX() {
struct A4 {
auto portrait() {
struct V {
- uint w = 160;
- uint h = 228;
- uint img_px = 450;
+ const uint w = 160;
+ const uint h = 228;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "12pt";
+ string name = "a4paper";
+ uint img_px = 450;
+ bool is_portrait = true;
}
return V();
}
auto landscape() {
struct H {
- uint w = 238;
- uint h = 160;
- uint img_px = 300;
+ const uint w = 238;
+ const uint h = 160;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "11pt";
+ string name = "a4paper";
+ uint img_px = 300;
+ bool is_portrait = false;
}
return H();
}
@@ -39,17 +49,27 @@ template outputLaTeX() {
struct A5 {
auto portrait() {
struct V {
- uint w = 112;
- uint h = 162;
- uint img_px = 280;
+ const uint w = 112;
+ const uint h = 162;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "a5paper";
+ uint img_px = 280;
+ bool is_portrait = true;
}
return V();
}
auto landscape() {
struct H {
- uint w = 152;
- uint h = 100;
- uint img_px = 190;
+ const uint w = 152;
+ const uint h = 100;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "a5paper";
+ uint img_px = 190;
+ bool is_portrait = false;
}
return H();
}
@@ -60,17 +80,27 @@ template outputLaTeX() {
struct B4 {
auto portrait() {
struct V {
- uint w = 140;
- uint h = 204;
- uint img_px = 356;
+ const uint w = 140;
+ const uint h = 204;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "b4paper";
+ uint img_px = 356;
+ bool is_portrait = true;
}
return V();
}
auto landscape() {
struct H {
- uint w = 200;
- uint h = 130;
- uint img_px = 260;
+ const uint w = 200;
+ const uint h = 130;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "b4paper";
+ uint img_px = 260;
+ bool is_portrait = false;
}
return H();
}
@@ -81,17 +111,27 @@ template outputLaTeX() {
struct Letter {
auto portrait() {
struct V {
- uint w = 166;
- uint h = 212;
- uint img_px = 468;
+ const uint w = 166;
+ const uint h = 212;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "letterpaper";
+ uint img_px = 468;
+ bool is_portrait = true;
}
return V();
}
auto landscape() {
struct H {
- uint w = 226;
- uint h = 166;
- uint img_px = 290;
+ const uint w = 226;
+ const uint h = 166;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "letterpaper";
+ uint img_px = 290;
+ bool is_portrait = false;
}
return H();
}
@@ -102,17 +142,27 @@ template outputLaTeX() {
struct Legal {
auto portrait() {
struct V {
- uint w = 168;
- uint h = 286;
- uint img_px = 474;
+ const uint w = 168;
+ const uint h = 286;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "legalpaper";
+ uint img_px = 474;
+ bool is_portrait = true;
}
return V();
}
auto landscape() {
struct H {
- uint w = 296;
- uint h = 166;
- uint img_px = 420;
+ const uint w = 296;
+ const uint h = 166;
+ string width = format(q"┃%dmm┃", w);
+ string height = format(q"┃%dmm┃", h);
+ string font_size = "0pt";
+ string name = "legalpaper";
+ uint img_px = 420;
+ bool is_portrait = false;
}
return H();
}
@@ -598,20 +648,25 @@ 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];
- string papertype = "a4";
uint pw = 0;
- switch (papertype) {
- case "a4": pw = (paper.a4.portrait.w - 20); break;
- case "a5": pw = (paper.a5.portrait.w - 20); break;
- case "b4": pw = (paper.b4.portrait.w - 20); break;
- case "letter": pw = (paper.letter.portrait.w - 20); break;
- case "legal": pw = (paper.legal.portrait.w - 20); break;
- default: pw = 0; break;
+ 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 "a5.portrait": pw = (paper.a5.portrait.w - 20); break;
+ case "a5.landscape": pw = (paper.a5.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 "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 = "";
@@ -681,15 +736,22 @@ string table(O,M)(
return _txt;
}
string latex_head(M)(
- M doc_matters,
+ M doc_matters,
+ string paper_size_orientation,
) {
- struct paperType {
+ struct paperTypeLatex {
string a4_portrait;
string a4_landscape;
+ string a5_portrait;
+ string a5_landscape;
+ string b4_portrait;
+ string b4_landscape;
string us_letter_portrait;
string us_letter_landscape;
+ string us_legal_portrait;
+ string us_legal_landscape;
}
- auto paper = paperType();
+ auto paper_type_latex = paperTypeLatex();
string _footer(M)(M doc_matters) {
string _ft = "\\lfoot[\\textrm{\\thepage}]";
string _ft_1 = format(q"┃{\tiny \href{%s}{%s}}┃", "http://sisudoc.org", "SiSU",);
@@ -718,26 +780,6 @@ string table(O,M)(
}
return _ft;
}
- paper.a4_portrait = format(q"┃
-\documentclass[12pt,a4paper,titlepage]{scrartcl}
-\setlength{\textheight}{228mm} \setlength{\textwidth}{160mm}
-┃",
- );
- paper.a4_landscape = format(q"┃
-\documentclass[11pt,a4paper,landscape,titlepage,twocolumn]{scrartcl}
-\setlength{\textheight}{160mm} \setlength{\textwidth}{238mm}
-┃",
- );
- paper.us_letter_portrait = format(q"┃
-\documentclass[12pt,letterpaper,titlepage]{scrartcl}
-\setlength{\textheight}{212mm} \setlength{\textwidth}{166mm}
-┃",
- );
- paper.us_letter_landscape = format(q"┃
-\documentclass[11pt,letterpaper,landscape,titlepage,twocolumn]{scrartcl}
-\setlength{\textheight}{166mm} \setlength{\textwidth}{226mm}
-┃",
- );
struct paperMargins {
string portrait;
string landscape;
@@ -786,12 +828,64 @@ string table(O,M)(
linkcolor=myred, %% \href{...} and \pageref{...}
┃",
);
+ string set_paper(P)(P paper_set,) {
+ string paper_type_description;
+ if (paper_set.is_portrait) {
+ paper_type_description = format(q"┃
+ \documentclass[%s,%s,titlepage]{scrartcl}
+ \setlength{\textheight}{%s} \setlength{\textwidth}{%s}
+ ┃",
+ paper_set.font_size,
+ paper_set.name,
+ paper_set.height,
+ paper_set.width,
+ );
+ } else {
+ paper_type_description = format(q"┃
+ \documentclass[%s,%s,landscape,titlepage,twocolumn]{scrartcl}
+ \setlength{\textheight}{%s} \setlength{\textwidth}{%s}
+ ┃",
+ paper_set.font_size,
+ paper_set.name,
+ paper_set.height,
+ paper_set.width,
+ );
+ }
+ return paper_type_description;
+ }
+ 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 "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 "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 "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;
+ }
+ string links_mono_or_color_set = links.mono.strip;
+ if (
+ (doc_matters.opt.action.latex_color_links)
+ || (paper_size_orientation ==
+ "a4.landscape" ||
+ "a5.landscape" ||
+ "b4.landscape" ||
+ "letter.landscape" ||
+ "legal.landscape")
+ ){
+ links_mono_or_color_set = links.color.strip;
+ }
string _latex_head = format(q"┃%%%% spine LaTeX output
%%%% Generated by: %s
%%%% D version: %s
%%%% LaTeX output last Generated on: %s
%%%% %s %s
+\usepackage{geometry}
%s
%s
\setlength{\marginparsep}{4mm}
@@ -967,12 +1061,12 @@ string table(O,M)(
doc_matters.opt.action.debug_do ? "" : doc_matters.generator_program.stime.strip,
doc_matters.generator_program.project_name.strip,
doc_matters.generator_program.url_home.strip,
- paper.a4_portrait.strip,
+ paper_size_orientation_latex.strip,
margins.portrait.strip,
multicol.portrait.strip,
lang.codes[doc_matters.src.language]["xlp"],
"english",
- links.mono.strip, // links.color.strip,
+ 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,
@@ -982,8 +1076,9 @@ string table(O,M)(
return _latex_head.strip;
}
string latex_body(D,M)(
- const D doc_abstraction,
- M doc_matters,
+ const D doc_abstraction,
+ M doc_matters,
+ string paper_size_orientation,
) {
string _latex_body = "";
bool _multicolumns = false;
@@ -1057,7 +1152,7 @@ string table(O,M)(
_txt = _txt.codeblock(obj, doc_matters);
goto default;
case "table":
- _txt = _txt.table(obj, doc_matters);
+ _txt = _txt.table(obj, doc_matters, paper_size_orientation);
goto default; // TODO
default:
_latex_body ~= _txt ~ "\n\n";
@@ -1144,7 +1239,8 @@ string table(O,M)(
return _latex_body;
}
string latex_tail(M)(
- M doc_matters,
+ M doc_matters,
+ string paper_size_orientation,
) {
string _latex_tail = format(q"┃
@@ -1156,8 +1252,9 @@ string table(O,M)(
return _latex_tail;
}
void writeOutputLaTeX(T,M)(
- const T latex_content,
- M doc_matters,
+ const T latex_content,
+ M doc_matters,
+ string paper_size_orientation,
) {
auto pth_latex = spinePathsLaTeX(doc_matters);
try {
@@ -1173,9 +1270,9 @@ string table(O,M)(
(pth_latex.latex_path_stuff).mkdirRecurse;
}
if (!(doc_matters.opt.action.quiet)) {
- writeln(" ", pth_latex.latex_file_with_path);
+ writeln(" ", pth_latex.latex_file_with_path(paper_size_orientation));
}
- auto f = File(pth_latex.latex_file_with_path, "w");
+ auto f = File(pth_latex.latex_file_with_path(paper_size_orientation), "w");
f.writeln(latex_content.head);
f.writeln(latex_content.content);
f.writeln(latex_content.tail);
@@ -1200,9 +1297,22 @@ string table(O,M)(
string tail;
}
auto latex = LaTeX();
- latex.head = latex_head(doc_matters);
- latex.content = latex_body(doc_abstraction, doc_matters);
- latex.tail = latex_tail(doc_matters);
- latex.writeOutputLaTeX(doc_matters);
+ foreach (paper_size_orientation; [
+ "a4.portrait",
+ "a4.landscape",
+ "letter.portrait",
+ "letter.landscape",
+ "a5.portrait",
+ "a5.landscape",
+ "b4.portrait",
+ "b4.landscape",
+ // "legal.portrait",
+ // "legal.landscape",
+ ]) {
+ latex.head = latex_head(doc_matters, paper_size_orientation);
+ latex.content = latex_body(doc_abstraction, doc_matters, paper_size_orientation);
+ latex.tail = latex_tail(doc_matters, paper_size_orientation);
+ latex.writeOutputLaTeX(doc_matters, paper_size_orientation);
+ }
}
}
diff --git a/src/doc_reform/io_out/paths_output.d b/src/doc_reform/io_out/paths_output.d
index 83c9728..7cd9051 100644
--- a/src/doc_reform/io_out/paths_output.d
+++ b/src/doc_reform/io_out/paths_output.d
@@ -491,8 +491,12 @@ template spinePathsLaTeX() {
string latex_path_stuff() {
return ((base.chainPath(base_filename(doc_matters.src.filename))).asNormalizedPath).array;
}
- string latex_file_with_path() {
- return ((base.chainPath(base_filename(doc_matters.src.filename) ~ "." ~ doc_matters.src.language ~ ".tex")).asNormalizedPath).array;
+ string latex_file_with_path(string paper_size_orientation) {
+ return ((base.chainPath(base_filename(doc_matters.src.filename)
+ ~ "." ~ doc_matters.src.language
+ ~ "." ~ paper_size_orientation
+ ~ ".tex")
+ ).asNormalizedPath).array;
}
string images() {
string image_dir = "image";