-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheatsheet.tex
188 lines (137 loc) · 7.06 KB
/
cheatsheet.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
%_% These lines starting with %_% are used as annotations for GNU source-highlight package to be able to selectively
%_% convert parts of this file into markup. These can be removed before using this file.
%_% Try: grep -v '^%_%' cheatsheet.tex
%_% Start HEADER
\documentclass[a4paper,extrafontsizes,12pt,twoside,openany]{memoir}
\chapterstyle{bianchi}
\aliaspagestyle{chapter}{empty}
\pagestyle{empty}
%_% End HEADER
%_% PARAGRAPHSTYLES
\setlength\parindent{0in}
\setlength\parskip{1ex}
%_% PARAGRAPHSTYLES
%_% XETEXPACKAGES
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage[dvipsnames,usenames]{xcolor}
%_% XETEXPACKAGES
%_% OTHERPACKAGES
\usepackage{fontspec}
\setromanfont[Mapping=tex-text]{Linux Libertine O}
\usepackage[colorlinks=true,urlcolor=blue,linkcolor=blue]{hyperref}
%_% OTHERPACKAGES
\aliasfontfeatureoption{Ligatures}{Historic}{Historical}
\XeTeXtracingfonts=1
\usepackage{lettrine}
\usepackage{tikz}
\usepackage{a4wide}
\newcommand{\showpart}[1]{\noindent\input{parts/#1}}
\newcommand{\HyperRef}{\href{http://www.tug.org/applications/hyperref/manual.html}{hyperref}\ }
\newcommand{\FontSpec}{\href{http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=fontspec}{fontspec}\ }
\newcommand{\TikZ}{\href{http://www.texample.net/tikz/examples/}{PGF/TikZ}\ }
\newcommand{\red}[1]{{\color{red}{#1}}}
\newcommand{\green}[1]{{\color{green}{#1}}}
\newcommand{\blue}[1]{{\color{blue}{#1}}}
\begin{document}
%_% TITLE
\begin{minipage}{\textwidth}
\title{Playing around with \LaTeX} \date{} \author{Aravind SV <[email protected]>}
\maketitle
\begin{abstract}
This is a bit of a cheatsheet as well as a starting template for some of my \LaTeX\ documents. This is not a comprehensive guide to anything in \LaTeX, but will provide external references to further documentation wherever possible. See the source of this document (available \href{http://github.com/arvindsv/LaTeX.Stuff/blob/master/cheatsheet.tex}{here}) to truly understand this.
\end{abstract}
\thispagestyle{empty}
\end{minipage}
%_% TITLE
\chapter{The Setup}
\section{The headers}
In this document, the \href{http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=memoir}{memoir} class is used at
12pt default, with the option to work with much higher font sizes. The chapter style, bianchi, is described in the
\href{ftp://tug.ctan.org/pub/tex-archive/macros/latex/contrib/memoir/memman.pdf}{documentation for the memoir class}.
The pagestyle is empty as I don't want any page numbers. The aliaspagestyle is sort of a hack so that even
chapter-opening pages don't have page numbers.
You might notice that there is a difference in the side margins between pages. This is because of the ``twoside'' option
mentioned above. This makes \LaTeX\ setup the pages for two-side printing by flipping the margins on even and odd pages.
\showpart{HEADER}
\section{Paragraph styling}
The default typesetting of paragraphs in \LaTeX\ is by indentation at the beginning of a paragraph. This has been changed
to no indent and then a bigger gap between the paragraphs, by modifying the \textbackslash{}parskip and \textbackslash{}parindent lengths.
\showpart{PARAGRAPHSTYLES}
\section{\XeTeX\ packages}
Since \XeTeX\ is being used, these three packages are normally included to be able to make the use of Unicode and some additional
functionality easier. The options passed to \href{http://www.ukern.de/tex/xcolor.html}{xcolor} to be able to use of names
instead of color codes are also needed by the \HyperRef package used below.
\showpart{XETEXPACKAGES}
\section{Font setup}
I'm using the wonderful \FontSpec package with
it's brilliant \href{http://tug.ctan.org/tex-archive/macros/xetex/latex/fontspec/fontspec.pdf}{documentation}. Also,
using the \HyperRef package to provide all the links you see in this document.
The main font being used is \href{http://linuxlibertine.sourceforge.net/}{Linux Libertine}. I'll explain what the
Mapping option is for in \autoref{fontspec-mapping}.
\showpart{OTHERPACKAGES}
\section{Title page}
The title page is very plain, and it is typeset using: \showpart{TITLE}
\chapter{More about fonts}
\section{Ligatures}
\FontSpec understands OpenType \href{http://en.wikipedia.org/wiki/Typographic\_ligature}{ligatures}. Look at the
difference between:
%_% LIGATURES
{\newcommand{\ligs}{O\red{ft}en o\red{ffi}ce o\red{ff}er \red{fj}ord.}
{\Huge {\addfontfeature{Ligatures=NoCommon} \ligs}} \\
{\Huge {\addfontfeature{Ligatures=Rare} \ligs}}}
%_% LIGATURES
This was typeset using: \showpart{LIGATURES}
\section{Mapping}\label{fontspec-mapping}
As you can see below, with the tex-text mapping all the usual quotation marks and the
\href{http://en.wikipedia.org/wiki/Dash#Em\_dash}{em-dashes} are automatically used.
%_% MAPPING
\begin{tabular}{l || l}
No tex-text mapping & {\addfontfeature{Mapping=} No---No" '' ``} \\
With tex-text mapping & {\addfontfeature{Mapping=tex-text} No---No" '' ``}
\end{tabular}
%_% MAPPING
This was typeset using: \showpart{MAPPING}
\section{More font features exposed}
%_% FONTFEATURES
\newcommand{\aff}{\addfontfeature}
\begin{tabular}{l || l}
Qu has a ligature & {\Huge \red{Qu}iet \red{Q}antas} \\
Slashed zero. New style & {\Huge {\aff{Numbers=SlashedZero} 0123456789}} \\
Old style numbers & {\Huge {\aff{Numbers=OldStyle} 0123456789}} \\
Fractions & {\Huge {\aff{Fractions=On} 1/3} vs 1/3} \\
Superiors & {\Huge {\aff{VerticalPosition=Superior}1234567890 Libertine}} \\
More ligatures & {\Huge {\aff{Ligatures=Historical}„\red{st}“ „\red{ct}“}}
\end{tabular}
%_% FONTFEATURES
This was typeset using: \showpart{FONTFEATURES}
\section{Drop caps}
%_% DROPCAP
\renewcommand{\LettrineFontHook}{\color{red!50!white}}
\lettrine[lines=3,loversize=0.2,findent=-2ex,nindent=1ex,slope=1.5ex]{A}{s} you can see, using the
\href{http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=lettrine}{lettrine} package, the first letter of this paragraph has been enlarged to ``drop'' down three lines. Drop caps are often seen at the beginning of novels, where the top of the first letter of the first word lines up with the top of the first sentence and drops down to the four or fifth sentence.
%_% DROPCAP
This was typeset using: \showpart{DROPCAP}
\section{Font transparency}
%_% FONTTRANSPARENCY
\begin{tikzpicture}
\node[scale=3,opacity=0.6]{\red{\HUGE W}};
\node[scale=3,opacity=0.7,xshift=3ex]{\blue{\HUGE S}};
\node[scale=3,opacity=0.6,xshift=5ex]{\color{yellow}{\HUGE P}};
\node[scale=3,opacity=0.4,xshift=7.5ex]{\green{\HUGE R}};
\end{tikzpicture}
%_% FONTTRANSPARENCY
\FontSpec supports font transparency, but it needs some support from the font, apparently. So, enter the brilliant \TikZ
package, with a \href{http://www.ctan.org/tex-archive/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}{very
comprehensive manual}.
This was typeset using: \showpart{FONTTRANSPARENCY}
\chapter{Miscallaneous}
\section{stackrel - One above another}
You can put one element above another by using stackrel as mentioned
\href{http://www.uz.ac.zw/science/maths/latex/stackrel.html}{here}:
Do this: \showpart{STACKREL}
It looks like this:
%_% STACKREL
H$_2$CO$_3$ $\stackrel{heat}{\longrightarrow}$ H$_2$O + CO$_2$
%_% STACKREL
\end{document}