Skip to content

Instantly share code, notes, and snippets.

@hukaidong
Last active May 29, 2024 22:54
Show Gist options
  • Save hukaidong/2a716c1506fc12a4e531d21b8c4a5a65 to your computer and use it in GitHub Desktop.
Save hukaidong/2a716c1506fc12a4e531d21b8c4a5a65 to your computer and use it in GitHub Desktop.
Latex Setting up Template

Latex Common Files, includes

  • A Makefile used for compile
  • A main.tex file as a note taking template
    • support per chapter quick cite to docs or webpages
    • support prettified code block showing
\documentclass{report}
% use geometry to set paper size in US letter
\usepackage[letterpaper]{geometry}
\reversemarginpar
\usepackage{todonotes}
\usepackage{fancyref}
\usepackage{xcolor}
\usepackage{soul}
\usepackage[outputdir=build/]{minted}
\usemintedstyle{sas}
\setminted{autogobble}
\usepackage{fontspec}
\setmonofont{JetBrainsMono}[
Path=./fonts/JetBrainsMono/,
Scale=MatchLowercase,
Extension = .ttf,
UprightFont=*-Regular,
BoldFont=*-Bold,
ItalicFont=*-Italic,
BoldItalicFont=*-BoldItalic
]
\usepackage{parskip} % paragraph with have no indent but wider vertical gap
\usepackage{graphicx} % figures
\usepackage{csquotes}
\usepackage{enumitem} % enumerate itemsep
\usepackage[
refsection=chapter,
citestyle=numeric,
sorting=none
]{biblatex}
\DeclarePrintbibliographyDefaults{
heading=subbibintoc,
title=See also:
}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=black,
urlcolor=cyan,
citecolor=blue,
}
%\includeonly{}
\title{Latex Setting up Template}
\author{Kaidong Hu}
\addbibresource{main.bib}
\begin{document}
\maketitle
\tableofcontents
\include{pages/chapter1}
\include{pages/chapter2}
\include{pages/chapter3}
\end{document}
SHELL = /bin/bash
# This Makefile is used to compile the LaTeX document.
# It requires user updates bibligraphy manually in order to avoid double
# compilation every time.
default: all
lualatex --shell-escape --interaction=nonstopmode --output-directory=build/ main.tex
@read -n1 -p "Open it? ([n]/y)" ans ; if [ "$$ans" = "y" ]; then zathura build/main.pdf & fi
build/pages:
mkdir -p build/pages
full: | build/pages
lualatex --shell-escape --interaction=nonstopmode --output-directory=build/ main.tex
biber build/main
lualatex --shell-escape --interaction=batchmode --output-directory=build/ main.tex
lualatex --shell-escape --interaction=batchmode --output-directory=build/ main.tex
show:
zathura build/main.pdf &
biber:
biber build/main
clean:
rm -rf build
all: | build/pages
.PHONY: default all clean biber
Content
\printbibliography
@misc{example_com,
title = {Example Domain Homepage},
url = {https://example.com/}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment