-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tex
184 lines (132 loc) · 5.52 KB
/
main.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
% Source: https://www.overleaf.com/latex/templates/book-template-for-amazon-kdp-leanpub-and-google-play-e-book-and-pdf-2023/ymygsdrsyvsq
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Check out the accompanying book, Even Better Books with LaTeX the Agile Way in 2023, for a discussion of the template and step-by-step instructions. https://amzn.to/3HqwgXM https://leanpub.com/eBBwLtAW/
% The template was originally created by Clemens Lode, LODE Publishing (www.lode.de), on 1/1/2023. Feel free to use this template for your book project!
% I would be happy if you included a short mention in your book in order to help others to create their own books, too ("Book template based on \textit{Even Better Books with LaTeX the Agile Way in 2023} by Clemens Lode").
% Contact me at [email protected] if you need help with the template or are interested in our editing and publishing services.
% And don't forget to follow us on Instagram! https://www.instagram.com/lodepublishing/ https://www.instagram.com/betterbookswithlatex/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% To create an EPUB file, select pdfLaTeX in the Menu in the top-left and choose the conversion method in the /latexmkrc file.
% Select document class scrbook to be in the two-page mode and accommodate for the binding of a printed book.
% The bibliography receives an entry in the table of contents but no number.
\documentclass[pagesize=auto,bibliography=totocnumbered]{scrbook}
\input{setup.tex}
\title{\mytitle}
% Load additional LaTeX libraries.
\input{lib/packages}
% Set up externalization to save all tikz pictures also as JPG files (for the ebook/HTML output).
\ifxetex
\else
\usetikzlibrary{external}
\tikzexternalize
% Modify the behavior of tikzpicture: convert the generated image PDF to a jpg and insert that jpg (instead of the PDF) into the document.
\tikzset{jpg export/.style={external/system call={pdflatex \tikzexternalcheckshellescape -interaction=batchmode -jobname "\image" "\texsource"; convert -gravity center -extent 1245 -strip -quality 100 -density 300 -transparent white "\image.pdf" "\image.jpg"},/pgf/images/external info,/pgf/images/include external/.code=\includegraphics{##1.jpg}}}
% Activate "jpg export" configuration.
\tikzset{jpg export}
% Output the pdf to an existing directory.
\tikzsetexternalprefix{tikz-cache/}
\fi
%%%%%%%%%%%%%%%%%
% Preamble
%%%%%%%%%%%%%%%%%
% Redefining the \nameref command to use italics formatting needs to be done in the preamble:
\makeatletter
\AtBeginDocument{\@ifdefinable{\myorg@nameref}{\LetLtxMacro\myorg@nameref\nameref\DeclareRobustCommand*{\nameref}[1]{\textit{\myorg@nameref{#1}}}}}
\makeatother
% (Only) printed books have indexes.
% Allow three columns for the index to save space.
% Start tracking index commands, which have to be in the main file.
\ifxetex
\usepackage{idxlayout}
\makeindex[title=Index,columns=3]
\else
% This package is needed only when using tex4ebook and when a standalone EPUB file is the goal.
% \usepackage{tex4ebook}
\fi
\begin{document}
\ifxetex
\else
% \coverimage[scale=0.8]{OEBPS/cover.jpg}
\fi
\input{style-guide.tex}
\pagestyle{empty}
%%%%%%%%%%%%%%%%%
% Front matter
%%%%%%%%%%%%%%%%%
\frontmatter
% Front matter chapter entries use Roman page numbering (i, ii, iii, iv, ...).
\pagenumbering{roman}
% Remove this line for your actual book. It is only for advertisement.
% \input{front/template-front}\blankpage
\input{front/half-title}\blankpage
% The additional title with the cover is not needed for e-books.
\ifxetex
\input{front/title}\newpage
\fi
\input{front/publisher}\newpage
\input{front/dedication}\blankpage
%\input{front/epigraph}\blankpage
\input{front/tableofcontents.tex}\blankpage
\input{front/foreword}\blankpage
\input{front/preface}\blankpage
\ifxetex
% Headers and Footers
\pagestyle{fancy}
\fancyhf{}
% Left-hand even page
\fancyhead[LE]{\nouppercase{\rightmark\hfill\leftmark}}
% Right-hand odd page
\fancyhead[RO]{\nouppercase{\leftmark\hfill\rightmark}}
% Left-hand even page / Right-hand odd page
\fancyfoot[LE,RO]{\thepage}
% Re-define plain style
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0pt} % optional: removes horizontal line in header
}
\fi
%%%%%%%%%%%%%%%
% Main matter
%%%%%%%%%%%%%%%
\mainmatter
% Reset to normal page numbering (1, 2, 3, ...).
\renewcommand*{\chapterpagestyle}{plain}
\pagenumbering{arabic}
\input{chapters}
%%%%%%%%%%%%%%%%%
% Back matter
%%%%%%%%%%%%%%%%%
\backmatter
% \input{chapters/04-tikz-examples.tex}\newpage
% \blankpage
% \input{back/advertisement}\blankpage
% TODO: Maybe fill the author page
% \input{back/author}\blankpage
% \input{back/thebooksstory}\blankpage
% \input{back/questions}\blankpage
% \index{XeLaTeX@\textit{XeLaTeX}|textbf}
% \input{back/ideas}\blankpage
% \index{XeLaTeX@\textit{XeLaTeX}|textbf}
% \input{back/glossary}\blankpage
% This adds a separate quotations page (sources in the e-book are already included in the text body).
% \ifxetex
% \input{back/quotations}\blankpage
% \fi
\input{back/bibliography}\blankpage
%%%%%%%%%%%%%%%%%
% Appendix
%%%%%%%%%%%%%%%%%
\appendix
\input{appendices}
% The index page exists only for printed PDFs.
\ifxetex
% This is an optional command to display a prologue before the index.
% \indexprologue{Replace index prologue with an own introduction (errata, formatting, abbreviations, etc.).}
% \printindex\blankpage
\printindex
\thispagestyle{empty}
\fi
% \input{back/amazon} % \blankpage
% \input{back/last}
\end{document}