added SVG to latex output

master
Kenton Hamaluik 4 years ago
parent d7c1bbbbcb
commit 464134953a

@ -33,6 +33,7 @@ The current LaTeX template requires the following packages to be installed:
* [textcomp](https://ctan.org/pkg/textcomp)
* [graphicx](https://ctan.org/pkg/graphicx)
* [float](https://ctan.org/pkg/float)
* [svg](https://ctan.org/pkg/svg)
The template also requires [XeTeX](https://www.tug.org/xetex/) and the following fonts to be available on your system:
@ -77,3 +78,5 @@ Finally, compile `printbook.tex` using `pdflatex`:
```sh
pdflatex printbook.tex
```
As a sample, you can view the compiled [book](book.pdf) and [printbook](printbook.pdf) files for this book to see how this can turn out.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//01-command-line.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/01-commonmark.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/02-syntax-highlighting.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/03-plantuml-diagrams.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/04-katex-formulas.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/05-images.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/06-tables.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/07-task-lists.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html" class = "current">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">
@ -100,7 +107,7 @@
<span class="placeholder"></span>
<a href="../03-frontmatter.html" alt="Front Matter">
<a href="../02-markdown&#x2f;08-links.html" alt="Links">
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="../icons.svg#icon-arrow-right">
@ -124,8 +131,8 @@
<div class="next-chapter">
<a href="../03-frontmatter.html">
<span>Next chapter: “Front Matter</span>
<a href="../02-markdown&#x2f;08-links.html">
<span>Next chapter: “Links</span>
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="../icons.svg#icon-arrow-right">

@ -0,0 +1,151 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The mkbook Book | Links</title>
<link rel="stylesheet" href="../style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="../favicon.ico" />
<meta property="og:title" content="The mkbook Book" />
<meta property="og:site_name" content="The mkbook Book" />
<meta property="og:type" content="book" />
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/08-links.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
<nav class="big">
<header>
<h1><a href="../index.html">The mkbook Book</a></h1>
<h2>by Kenton Hamaluik</h2>
</header>
<ol>
<li>
<a href="../01-command-line.html">Command-line Interface</a>
</li>
<li>
<a href="../02-markdown/index.html">Markdown</a>
<ol>
<li><a href="../02-markdown/01-commonmark.html">CommonMark</a></li>
<li><a href="../02-markdown/02-syntax-highlighting.html">Syntax Highlighting</a></li>
<li><a href="../02-markdown/03-plantuml-diagrams.html">PlantUML Diagrams</a></li>
<li><a href="../02-markdown/04-katex-formulas.html">KaTeX (Math) Formulas</a></li>
<li><a href="../02-markdown/05-images.html">Images</a></li>
<li><a href="../02-markdown/06-tables.html">Tables</a></li>
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html" class = "current">Links</a></li>
</ol>
</li>
<li>
<a href="../03-frontmatter.html">Front Matter</a>
</li>
<li>
<a href="../04-structure.html">Structure</a>
</li>
<li>
<a href="../05-customization.html">Customization</a>
</li>
<li>
<a href="../06-how-it-works.html">How it Works</a>
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">
<span>
<a href="../index.html" alt="Table of Contents">
<span class="icon">
<svg class="icon-list-ol">
<use xlink:href="../icons.svg#icon-list-ol">
</svg>
</span>
</a>
<a href="../02-markdown&#x2f;07-task-lists.html" alt="Task Lists">
<span class="icon">
<svg class="icon-arrow-left">
<use xlink:href="../icons.svg#icon-arrow-left">
</svg>
</span>
</a>
</span>
<span class="title">Links</span>
<span>
<span class="placeholder"></span>
<a href="../03-frontmatter.html" alt="Front Matter">
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="../icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</span>
</nav>
<article>
<h1 class="title">Links</h1>
<p><em>mkbook</em> uses standard <em>MarkDown</em> notation for links:</p>
<pre style="background-color:#2d2d2d;">
<span style="color:#d3d0c8;">[link text](link url)
</span></pre>
<p>Links can be separated into three types:</p>
<ol>
<li>External links (prepended by <code>http://</code> or <code>https://</code>)</li>
<li>Internal links (relative path names)</li>
<li>Reference links (prepended by <code>ref://</code> and then followed by the chapter title) to refer to other chapters in the book**</li>
</ol>
<p><strong>Note</strong>: Reference links arent implemented yet!</p>
<div class="next-chapter">
<a href="../03-frontmatter.html">
<span>Next chapter: “Front Matter”</span>
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="../icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</div>
<footer><p>&copy; 2019 Kenton Hamaluik</p></footer>
</article>
</body>
</html>

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//02-markdown/index.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="../02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="../02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="../07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//03-frontmatter.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">
@ -84,7 +91,7 @@
</a>
<a href="02-markdown&#x2f;07-task-lists.html" alt="Task Lists">
<a href="02-markdown&#x2f;08-links.html" alt="Links">
<span class="icon">
<svg class="icon-arrow-left">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//04-structure.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//05-customization.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">

@ -12,7 +12,7 @@
<meta property="og:url" content="https://hamaluik.github.io/mkbook//06-how-it-works.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
@ -47,6 +47,8 @@
<li><a href="02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -71,6 +73,11 @@
</li>
<li>
<a href="07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">
@ -100,7 +107,13 @@
<span class="placeholder"></span>
<span class="placeholder"></span>
<a href="07-latex-output.html" alt="LaTeX Output">
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</span>
</nav>
@ -127,6 +140,16 @@
<div class="next-chapter">
<a href="07-latex-output.html">
<span>Next chapter: “LaTeX Output”</span>
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</div>
<footer><p>&copy; 2019 Kenton Hamaluik</p></footer>
</article>

@ -0,0 +1,181 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The mkbook Book | LaTeX Output</title>
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" />
<meta property="og:title" content="The mkbook Book" />
<meta property="og:site_name" content="The mkbook Book" />
<meta property="og:type" content="book" />
<meta property="og:url" content="https://hamaluik.github.io/mkbook//07-latex-output.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body>
<nav class="big">
<header>
<h1><a href="index.html">The mkbook Book</a></h1>
<h2>by Kenton Hamaluik</h2>
</header>
<ol>
<li>
<a href="01-command-line.html">Command-line Interface</a>
</li>
<li>
<a href="02-markdown/index.html">Markdown</a>
<ol>
<li><a href="02-markdown/01-commonmark.html">CommonMark</a></li>
<li><a href="02-markdown/02-syntax-highlighting.html">Syntax Highlighting</a></li>
<li><a href="02-markdown/03-plantuml-diagrams.html">PlantUML Diagrams</a></li>
<li><a href="02-markdown/04-katex-formulas.html">KaTeX (Math) Formulas</a></li>
<li><a href="02-markdown/05-images.html">Images</a></li>
<li><a href="02-markdown/06-tables.html">Tables</a></li>
<li><a href="02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="02-markdown/08-links.html">Links</a></li>
</ol>
</li>
<li>
<a href="03-frontmatter.html">Front Matter</a>
</li>
<li>
<a href="04-structure.html">Structure</a>
</li>
<li>
<a href="05-customization.html">Customization</a>
</li>
<li>
<a href="06-how-it-works.html">How it Works</a>
</li>
<li>
<a href="07-latex-output.html" class = "current">LaTeX Output</a>
</li>
</ol>
</nav>
<nav class="small">
<span>
<a href="index.html" alt="Table of Contents">
<span class="icon">
<svg class="icon-list-ol">
<use xlink:href="icons.svg#icon-list-ol">
</svg>
</span>
</a>
<a href="06-how-it-works.html" alt="How it Works">
<span class="icon">
<svg class="icon-arrow-left">
<use xlink:href="icons.svg#icon-arrow-left">
</svg>
</span>
</a>
</span>
<span class="title">LaTeX Output</span>
<span>
<span class="placeholder"></span>
<span class="placeholder"></span>
</span>
</nav>
<article>
<h1 class="title">LaTeX Output</h1>
<p><em>mkbook</em> can also export a <a href="https://www.latex-project.org/">LaTeX</a> file which can be used to convert your book to a beatiful, ready-to-print <a href="https://en.wikipedia.org/wiki/PDF">PDF</a>. This feature is still under heavy development as its not quite as smooth as I would like, and the generated <code>.tex</code> document is perhaps a bit too customized—Im still exploring this.</p>
<p>For now, however, you can convert your book into a single <code>.tex</code> file with the following command which will create the file <code>./print/book.tex</code> along with any images needed to render the book:</p>
<pre style="background-color:#2d2d2d;">
<span style="color:#6699cc;">mkbook</span><span style="color:#d3d0c8;"> build</span><span style="color:#f2777a;"> -l</span><span style="color:#d3d0c8;"> ./print/book.tex
</span></pre>
<p>Note that this command is more about preparing a <code>.tex</code> file that you can then further customize for your own book than having a complete, ready-to-go PDF that is entirely your own—the current LaTeX template that gets generated works for me but it may not work for you.</p>
<h1><a href="#images" aria-hidden="true" class="anchor" id="headerimages"></a>Images</h1>
<p>If an image in the document is an external image (i.e. it starts with <code>http://</code> or <code>https://</code>), <em>mkbook</em> will attempt to download the image the same directory that the generated LaTeX document resides in. If it cannot do so, it will tell you. If, on the other hand, the image is in the source tree, it will be copied over the same way that any other asset is and should be available to the LaTeX file.</p>
<p>Similar to this, <em>mkbook</em> will attempt to render any <code>plantuml</code> code sections into <code>.svg</code> files which also get included in the book.</p>
<h1><a href="#building-the-book" aria-hidden="true" class="anchor" id="headerbuilding-the-book"></a>Building the Book</h1>
<p>The current LaTeX template requires the following packages to be installed:</p>
<ul>
<li><a href="https://ctan.org/pkg/ulem">ulem</a></li>
<li><a href="https://ctan.org/pkg/fontspec">fontspec</a></li>
<li><a href="https://ctan.org/pkg/sectsty">sectsty</a></li>
<li><a href="https://ctan.org/pkg/xcolor">xcolor</a></li>
<li><a href="https://ctan.org/pkg/minted">minted</a></li>
<li><a href="https://ctan.org/pkg/amsmath">amsmath</a></li>
<li><a href="https://ctan.org/pkg/amssymb">amssymb</a></li>
<li><a href="https://ctan.org/pkg/enumitem">enumitem</a></li>
<li><a href="https://ctan.org/pkg/textcomp">textcomp</a></li>
<li><a href="https://ctan.org/pkg/graphicx">graphicx</a></li>
<li><a href="https://ctan.org/pkg/float">float</a></li>
<li><a href="https://ctan.org/pkg/svg">svg</a></li>
</ul>
<p>The template also requires <a href="https://www.tug.org/xetex/">XeTeX</a> and the following fonts to be available on your system:</p>
<ul>
<li><a href="https://github.com/skosch/Crimson">Crimson</a></li>
<li><a href="https://www.fontsquirrel.com/fonts/poppins">Poppins</a></li>
<li><a href="https://github.com/adobe-fonts/source-code-pro">Source Code Pro</a></li>
</ul>
<p>Finally, in order to color the source code, you must have <a href="https://pygments.org/">Pygments</a> installed and the <code>pygmentize</code> executable must be available on your path.</p>
<p>If you meet all these requirements, you can build the book using <code>xelatex</code>. Assuming you built the <code>book.tex</code> file in the <code>print</code> directory as above:</p>
<pre style="background-color:#2d2d2d;">
<span style="color:#66cccc;">cd</span><span style="color:#d3d0c8;"> print
</span><span style="color:#6699cc;">xelatex</span><span style="color:#f2777a;"> -shell-escape</span><span style="color:#d3d0c8;"> book.tex
</span><span style="color:#6699cc;">xelatex</span><span style="color:#f2777a;"> -shell-escape</span><span style="color:#d3d0c8;"> book.tex
</span></pre>
<p>Note that the <code>-shell-escape</code> argument is required in order to get <em>Pygments</em> to colour your source code, and the <code>xelatex</code> command is run twice in order to properly build the table of contents.</p>
<p>Note also that in the current template, the pages that are created are 5.5 inches by 8 inches. This is to facilitate booklet printing on North American letter paper. Feel free to change this in the generated <code>book.tex</code> file before compiling if you need to.</p>
<h2><a href="#compiling-a-booklet" aria-hidden="true" class="anchor" id="headercompiling-a-booklet"></a>Compiling a Booklet</h2>
<p>If you want to easily print this book as a booklet, you can take one more step to arrange the pages so that a simple duplex print on any printer will produce signatures that you can easily bind yourself (there are many tutorials online for doing this, I recommend <a href="https://mostlymaths.net/2009/04/easy-paperback-book-binding-how-to.html/">Easy paperback book binding how-to</a> by Rubén Berenguel).</p>
<p>The first step is to create a file alongside your compiled <code>book.pdf</code> file called <code>printbook.tex</code> with the contents as such:</p>
<pre style="background-color:#2d2d2d;">
<span style="color:#cc99cc;">\documentclass</span><span style="color:#d3d0c8;">[letterpaper]{</span><span style="color:#ffcc66;">article</span><span style="color:#d3d0c8;">}
</span><span style="color:#cc99cc;">\usepackage</span><span style="color:#d3d0c8;">[final]{</span><span style="color:#ffcc66;">pdfpages</span><span style="color:#d3d0c8;">}
</span><span style="color:#cc99cc;">\begin</span><span style="color:#d3d0c8;">{document}
</span><span style="color:#66cccc;">\includepdf</span><span style="color:#d3d0c8;">[pages=-,nup=1x2,landscape,signature=32]{book.pdf}
</span><span style="color:#cc99cc;">\end</span><span style="color:#d3d0c8;">{document}
</span></pre>
<p>You can change the value of <code>signature</code> as you like, but keep it a multiple of 4. The <a href="https://en.wikipedia.org/wiki/Section_(bookbinding)">signature</a> is the number of pages (<strong>not</strong> sheets of paper) which get combined into a “mini-booklet”, and the final book is a combination of all of the signatures (“mini-booklets”) to make the full book. Essentially, if you divide this number by 4, youll get the number of sheets of paper that youll have to staple together at a time. For a signature of 32 pages, this will mean stapling together 8 pages at a time.</p>
<p>Note that if you have a relatively short book, it may be advantageous to just do all of the books pages into one signature, in this case make the signature the next multiple-of-four value higher than the total number of sheets in the <code>book.pdf</code> file. For example: if <code>book.pdf</code> contains 45 pages, make <code>signature=48</code> to put everything into a single signature.</p>
<p>Finally, compile <code>printbook.tex</code> using <code>pdflatex</code>:</p>
<pre style="background-color:#2d2d2d;">
<span style="color:#6699cc;">pdflatex</span><span style="color:#d3d0c8;"> printbook.tex
</span></pre>
<p>As a sample, you can view the compiled <a href="book.pdf">book</a> and <a href="printbook.pdf">printbook</a> files for this book to see how this can turn out.</p>
<footer><p>&copy; 2019 Kenton Hamaluik</p></footer>
</article>
</body>
</html>

Binary file not shown.

@ -15,14 +15,14 @@
&lt;p&gt;If youre not familiar with &lt;em&gt;mdbook&lt;&#x2f;em&gt;, &lt;em&gt;mkbook&lt;&#x2f;em&gt; is a tool to convert a collection of &lt;a href=&quot;https:&#x2f;&#x2f;commonmark.org&#x2f;&quot;&gt;Markdown&lt;&#x2f;a&gt; files into a static website &#x2f; book which can be published online. It was created to help me write documentation with minimum fuss while presenting it in an easy-to-consume manner.&lt;&#x2f;p&gt;
" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-12-09T07:02:23.053503163+00:00" />
<meta property="book:release_date" content="2019-12-12T22:19:33.053441804+00:00" />
</head>
<body class="toc">
<header>
<h1>The mkbook Book</h1>
<h2>by Kenton Hamaluik</h2>
<time datetime="2019-12-09T07:02:23.053503163+00:00">Dec 9, 2019</time>
<time datetime="2019-12-12T22:19:33.053441804+00:00">Dec 12, 2019</time>
</header>
<article>
<p><em>mkbook</em> is my simpler alternative to <a href="https://crates.io/crates/mdbook"><em>mdbook</em></a> which is a great tool, however I really dislike some of the decisions they took—such as relying on javascript for highlighting and navigation and including a lot of bells and whistles such as javascript-based search.</p>
@ -58,6 +58,8 @@
<li><a href="02-markdown/07-task-lists.html">Task Lists</a></li>
<li><a href="02-markdown/08-links.html">Links</a></li>
</ol>
</li>
@ -82,6 +84,11 @@
</li>
<li>
<a href="07-latex-output.html">LaTeX Output</a>
</li>
</ol>
</nav>
<footer><p>&copy; 2019 Kenton Hamaluik</p></footer>

Binary file not shown.

@ -67,7 +67,5 @@ pub fn create_plantuml_svg(src: &str) -> Result<String, Box<dyn std::error::Erro
return Err(Box::from("plantuml failed"));
}
let svg: String = String::from_utf8(output.stdout)?;
let svg = svg.replace(r#"<?xml version="1.0" encoding="UTF-8" standalone="no"?>"#, "");
Ok(format!("<figure>{}</figure>", svg))
Ok(svg)
}

@ -77,8 +77,11 @@ fn format_code(lang: &str, src: &str) -> Result<FormatResponse, Box<dyn std::err
// render plantuml code blocks into an inline svg
if lang == "plantuml" {
let svg = create_plantuml_svg(src)?;
let svg = svg.replace(r#"<?xml version="1.0" encoding="UTF-8" standalone="no"?>"#, "");
return Ok(FormatResponse {
output: create_plantuml_svg(src)?,
output: format!("<figure>{}</figure>", svg),
include_katex_css: false,
});
}

@ -2,6 +2,7 @@ use std::path::{Path, PathBuf};
use askama::Template;
use std::{fs, io};
use comrak::ComrakOptions;
use crate::extensions::create_plantuml_svg;
mod filters;
@ -139,7 +140,27 @@ fn format_node<'a, P: AsRef<Path>>(section_offset: u32, dest_path: P, node: &'a
let source = std::str::from_utf8(&node_code_block.literal).expect("valid utf-8");
if lang.to_lowercase() == "plantuml" {
log::debug!("TODO: render plantuml");
let digest = md5::compute(source.as_bytes());
let output_path = dest_path.as_ref().join(format!("{:x?}.svg", digest));
let svg = match create_plantuml_svg(&source) {
Ok(svg) => svg,
Err(e) => {
log::error!("failed to create SVG: {:?}", e);
return;
}
};
if let Err(e) = std::fs::write(&output_path, svg) {
log::error!("failed to write SVG to file `{}`: {:?}", output_path.display(), e);
return;
}
output.push_str("\\begin{figure}[H]\n");
output.push_str("\\centering\n");
output.push_str("\\includesvg{");
output.push_str(&format!("{:x?}.svg", digest));
output.push_str("}\n");
output.push_str("\\end{figure}\n");
return;
}
else if lang.to_lowercase() == "katex" {

@ -1,7 +1,7 @@
\documentclass[twoside, 10pt]{book}
% booklet-sized pages
\usepackage[papersize={5.5in, 8.5in}, left=0.25in, right=0.125in, top=0.125in, bottom=0.125in]{geometry}
\usepackage[papersize={5.5in, 8.5in}, left=0.75in, right=0.5in, top=0.85in, bottom=0.85in]{geometry}
% for strike-outs
\usepackage{ulem}
@ -46,6 +46,7 @@
% images
\usepackage{graphicx}
\usepackage{svg}
\makeatletter
\def\maxwidth#1{\ifdim\Gin@nat@width>#1 #1\else\Gin@nat@width\fi}
\makeatother

Loading…
Cancel
Save