-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatex-sample.tex
executable file
·232 lines (183 loc) · 6.86 KB
/
latex-sample.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
\documentclass[14pt, bibliography=totoc, index=totoc, listof=totoc]{report}
% language characters and special characters
\usepackage[utf8]{inputenc}
% coding of characters in pdf documents
\usepackage[T1]{fontenc}
% decrease distance between figure and caption
\usepackage[skip=5pt]{caption}
% to configure spacing on enumeration items
\usepackage{enumitem}
% used to specify the paragraph indent
\usepackage{parskip}
% for specifying column width in tables
\usepackage{array}
% for using code listings with \lstlisting
\usepackage{listings}
% for using \multicolumn
\usepackage{multirow}
% for colored text
\usepackage{xcolor}
% for more text sizes
% from smallest to largest:
% \tiny 5pt
% \scriptsize 7pt
% \footnotesize 8pt
% \small 9pt
% \normalsize 10pt
% \large 12pt
% \Large 14.4pt
% \LARGE 17.28pt
% \huge 20.74pt
% \Huge 24.88pt
\usepackage{extsizes}
% for adding links using \href{link}{text} or \url{link} and references (\ref{}) to chapters
\usepackage{hyperref}
% removing the book margin
% setting the size and position(?) of the header, so header line with chapter and section is in the right position
% setting where the page ends as well
\usepackage[nomarginpar, margin=.9in, headsep=1.05cm,headheight=0.35cm, top=3.2cm, bottom=2cm]{geometry}
% configuring the graphicx package to use specified path automatically
\usepackage{graphicx}
% use images by using \includegraphics{img_without_extension}
\graphicspath{{img/}}
% times new roman font
\usepackage{times}
% in order to use [H] (precise positioning) on figures
\usepackage{float}
% nice chapter header
% other options: https://mirror.easyname.at/ctan/macros/latex/contrib/fncychap/fncychap.pdf
\usepackage[Bjornstrup]{fncychap}
% used to generate lorem ipsum
\usepackage{lipsum}
% adding a header line with the chapter name
\usepackage{fancyhdr}
% configuring chapter distances
\usepackage{etoolbox}
\pagestyle{fancy}
% clear only header, not footer! (\fancyhf)
\fancyhead{}
% on an odd page number (in this case, on every page), show the chapter on the left side and the section on the right side
% leftmark == chapter name
% rightmark == section name
\fancyhead[OL]{\small\nouppercase\leftmark}
\fancyhead[OR]{\small\nouppercase\rightmark}
% show page number on left side of header
% \fancyhead[OL]{\thepage}
% the following lines are used because otherwise, the "Chapter 1: Blabla" text on a new chapter is in the middle of the page, which bothers me
\makeatletter
% decrease space before a numbered chapter
\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{\vspace*{-90\p@}}{}{}
% decrease space before an unnumbered chapter
\patchcmd{\@makeschapterhead}{\vspace*{50\p@}}{\vspace*{-66\p@}}{}{}
% decrease space after a numbered chapter
\patchcmd{\DOTI}{\vskip 40\p@}{\vskip 20\p@}{}{}
% decrease space after an unnumbered chapter
\patchcmd{\DOTIS}{\vskip 40\p@}{\vskip -20\p@}{}{}
% code listings
\definecolor{code-backcolor}{RGB}{245, 245, 237}
\lstset{
breaklines=true,
escapeinside={(*}{*)},
backgroundcolor=\color{code-backcolor},
basicstyle=\ttfamily\small\linespread{0.4},
abovecaptionskip=9pt,
numbers=left,
stepnumber=1,
showstringspaces=false,
tabsize=2,
captionpos=b,
aboveskip=25px,
belowskip=0px,
breakatwhitespace=false,
xleftmargin=0.70cm,
% make sure umlauts can be printed in \lstlisting
% may need to be edited for other languages
literate=
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{{\ss}}1
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
{~}{{\textasciitilde}}1
}
% increasing length between paragraphs
\setlength{\parskip}{\baselineskip}%
% removing paragraph indent
\setlength{\parindent}{0pt}
% changing itemize and enumerate:
% less distance between top paragraph and list
% no distance between list items
% more distance after list and bottom paragraph
\setlist[itemize]{noitemsep, topsep=-10pt, after=\vspace{0.5cm}}
\setlist[enumerate]{noitemsep, topsep=-10pt, after=\vspace{0.5cm}}
% add space above images
\setlength{\intextsep}{10pt}
% add bibliography package
\usepackage[backend=biber,style=authoryear-comp,sorting=ynt]{biblatex}
\setlength{\bibitemsep}{0.9cm}
% set text for when a website was last visited (urldate)
\renewbibmacro*{urldate}{
(last visited on \printfield{urlday}.\printfield{urlmonth}.\printfield{urlyear})
}
% add bibliography
\addbibresource{example-bibliography.bib}
% title page texts
\title{Sample}
\author{Author}
\date{\today}
\begin{document}
\maketitle % use title in document
% print a table of contents
\tableofcontents
% print a list of figures
\listoffigures
% print a list of tables
% \listoftables
% print a table of code listings
% \lstlistoflistings
\chapter{Chapter}
This is some sample text in a chapter.
\section{Section}
This is some sample text in a section.
\subsection{Subsection}
This is some sample text in a subsection.
The following is an itemized list.
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
The following is an enumerated list.
\begin{enumerate}
\item Item 1
\item Item 2
\item Item 3
\end{enumerate}
This is \textit{italicized} text.
This is \textbf{bold} text.
This is \verb|inline code| text.
The following is a \href{https://www.linux.org/}{link}.
\pagebreak
\section{Another section}
Figure \ref{fig:example} shows an example image.
\begin{figure}[H]
\centering
\vspace{0.4cm}
\fbox{\includegraphics[width=0.5\linewidth]{example_img}}
% \copyrightbox[r]{\fbox{\includegraphics[width=0.5\linewidth]{example_img}}}{\textcopyright\ Author (CC BY-SA 3.0)}
\caption{An image}
\label{fig:example}
\vspace{-0.4cm}
\end{figure}
Listing \ref{code:example} shows a piece of code.
\begin{lstlisting}[caption=Code example, label=code:example, language=python]
def lorem(ipsum : str) -> None:
print(ipsum)
\end{lstlisting}
\lipsum[1]
\pagebreak
This is an example for a citation \parencite{typo3-fluid-if-else}. Here is another example \parencite{linux-handbuch}. These works only show up in the final document's bibliography if they are cited somewhere.
\printbibliography[heading=bibintoc, title={References}]
\end{document}