Debian Codegraph @

texmf-dist/source/latex/cheatsheet/cheatsheet.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (c) 2016 by Adrian C. Hinrichs
4 %
5 % This File may be distributed and/or modified under the condition of the below
6 % license.
7 %
8 %
9 % MIT License
10 %
11 %
12 %
13 % Copyright (c) 2017
14 %
15 %
16 %
17 % Permission is hereby granted, free of charge, to any person obtaining a copy
18 % of this software and associated documentation files (the "Software"), to deal
19 % in the Software without restriction, including without limitation the rights
20 % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21 % copies of the Software, and to permit persons to whom the Software is
22 % furnished to do so, subject to the following conditions:
23 %
24 % The above copyright notice and this permission notice shall be included in all
25 % copies or substantial portions of the Software.
26 %
27 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28 % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29 % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30 % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31 % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32 % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 % SOFTWARE.
34 % \fi
35 \def\csfileversion{v1.0}
36 \def\csfiledate{2017/08/18}
37 % \iffalse
38 %<*driver>
39 \ProvidesFile{cheatsheet.dtx}
40 %</driver>
41 %<class>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
42 %<class>\ProvidesClass{cheatsheet}[\csfiledate\space\csfileversion]
43 %<*driver>
44 \documentclass[a4paper,landscape,columns=3]{cheatsheet}
45 \usepackage[ngerman,english]{babel}
46 \usepackage[autostyle,german=guillemets]{csquotes}
47 %\usepackage{amssymb}
48 %\usepackage{amsmath}
49 %\usepackage{longtable}
50 %\usepackage{soul}
51 \usepackage{listings}
52
53 \title{The \textsf{cheatsheet} class\footnotemark}
54 \author{Adrian
55 C. Hinrichs\\
56 \href{mailto:[email protected]}{[email protected]}
57 }
58 \date{\today}
59
60
61 \begin{document}
62 %\begin{multicols}{3}
63 \maketitle
64 \footnotetext{This document corresponds to \textsf{cheatsheet.cls}
65 \csfileversion, dated \csfiledate}
66 \section{Abstract}
67 This Class provides a clean, multi-column design intended for Cheat
68 Sheets.\\
69
70 It imports the most useful Packages and encloses the document in a
71 multicol-environment.
72 \section{Options}
73 \subsection{(Not)Inherited options}
74 Because the class is inherited by article, every Option that can be
75 passed to article, will be passed to article. There is only one
76 restriction:
77 \begin{description}
78 \item[\texttt{twocolumn}] Because I create the columns with
79 \texttt{multicol}, \texttt{article} would screw up the layout if
80 \texttt{twocoloumn} would be passed, so this raises an error.
81 \end{description}
82 \subsection{Own options}
83 \begin{description}
84 \item[\texttt{columns=<x>}] Sets the number of columns. Note that 1
85 column is not supported by \lstinline{multicol} and will be set to
86 2. standard value is 4
87 \end{description}
88 \section{Commands}
89 None so far.
90 \vfill\null\columnbreak
91 \section{Dependencies}
92
93 This class is build uppon \textrm{article}, so of course the first
94 dependency is:
95 \newcommand{\dep}[4]{\item[\texttt{#1}]\textsc{#2}, \url{#3},\\#4}{}
96 \begin{description}
97 \dep{article}{1992 Leslie Lamport, 1994-97 Frank Mittelbach
98 Johannes Braams, The \LaTeX-Team}{https://www.ctan.org/pkg/kvoptions}
99 \end{description}
100 These are all required packages:
101 \begin{description}
102 \dep{amsmath}{The \LaTeX--Team, Frank Mittelbach, Rainer Sch\"opf, et
103 al.}{https://www.ctan.org/pkg/amsmath}{For better math-typesetting}
104 \dep{amssymb}{American Mathematical
105 Society}{mirror.ctan.org/fonts/amsfonts/doc/amssymb.pdf}{For more
106 mathematical symbols}
107 \dep{csqutotes}{Philipp Lehman (inaktiv), Joseph
108 Wright}{https://www.ctan.org/pkg/csquotes}{For better citation}
109 \dep{etoolbox}{Philipp Lehman (inactive), Joseph
110 Wright}{https://www.ctan.org/pkg/etoolbox}{The package is a toolbox
111 of programming facilities geared primarily towards \LaTeX class and
112 package authors}
113 \dep{fontenc}{The
114 \LaTeX{}--Team}{https://www.ctan.org/pkg/fontenc}{The package
115 allows the user to select font encodings}
116 \dep{hyperref}{Sebastian Rahtz, Heiko
117 Oberdiek}{https://www.ctan.org/pkg/hyperref}{I originally did not
118 want to include it, but apparently I can not use
119 \textbackslash\lstinline{AtBeginDocument} if hyperref is not the
120 first Package to be loaded.\\
121 If anyone has an other solution, please let me know!}
122 \dep{kvoptions}{Heiko Oberdiek}{https://www.ctan.org/pkg/kvoptions}{for
123 \texttt{key=value}--style options}
124 \dep{libertine}{Bob Tennent}{https://www.ctan.org/pkg/libertine}{ A
125 nicer than default font (at least in my opinion)}
126 \dep{mdframed}{Marco Daniel, Elke
127 Schubert}{https://www.ctan.org/pkg/mdframed}{Provides breakable,
128 colored, framed boxes}
129 \dep{multicol}{The \LaTeX--Team, Frank
130 Mittelbach}{https://www.ctan.org/pkg/multicol}{Provides the
131 multicolumn--layout}
132 \dep{suffix}{David Kastrup}{https://www.ctan.org/pkg/suffix}{Makes
133 it easy to define \texttt{$\backslash$macro*} commands}
134 \dep{xcolor}{Uwe Kern}{https://www.ctan.org/pkg/xcolor}{Based uppon
135 \lstinline{color}, it provides colors}
136 \dep{xifthen}{Josselin Noirel}{https://www.ctan.org/pkg/xifthen}{For
137 if--else--structures}
138 \end{description}
139 \section{Development and support}
140
141 The class is developed at \emph{GitHub}:
142 \begin{quote}
143 \url{https://github.com/ACHinrichs/LaTeX-templates}
144 \end{quote}
145 Please refer to that site for any bug report or development
146 information.
147 \section{Changelog}
148 \begin{description}
149 \item[v0.2 - 2017/07/06] Initial
150 \item[v0.4 - 2017/07/29] Enclose document with multicol (technicaly,
151 it is the other way around)
152 \item[v0.8 - 2017/08/18] Change names to match CTANS requirements,\\
153 Fix a possibly old Bug, could date back to \lstinline{v0.4}
154 \end{description}
155 \paragraph{Note: }The minor version of stable versions is always even,
156 the minor version of unstable versions is always odd. There are no
157 unstable patch--versions, instead unstable versions get an
158 alphabetical suffix.\\
159
160 \section{Credits}
161 This class is not based upon, but inspired by a document I found on
162 \textsc{Stackoverflow}. Unfortunately, I can't find it anymore. If
163 you happen to find it, feel free to open a Pull-Request (or an Issue,
164 or send me an E-Mail) , so that I can credit him or her!
165
166 \section{Known Bugs}
167 \begin{itemize}
168 \item When trying to use \lstinline{\lstinline} in the label of an
169 \lstinline{description}--item, the code--snippet will be displayed
170 at the bottom of the column. Possibly relates to floats not being
171 supported by \lstinline{multicol}%At least in this ducoment
172 \end{itemize}
173 \section{Examples}
174 For examples, pleas see the Git-Repo at
175 \url{https://github.com/ACHinrichs/LaTeX-templates} or my
176 CheatSheets at
177 \url{https://github.com/ACHinrichs/CheatSheets}\textbf{ or this
178 document!}
179
180 \section{Minimal Document}
181 \begin{lstlisting}[language={[LaTeX]TeX}]
182 \documentclass[a4paper,landscape,columns=3]{CheatSheet}
183
184 \title{Cheat--Sheet}
185 \author{A. Uthor\\\href{mailto:[email protected]}{[email protected]}}
186 \date{\today}
187 \begin{document}
188 \maketitle
189 \section{Some things}
190 Cheats
191 \section{Other things}
192 more Cheats
193 \end{document}
194 \end{lstlisting}
195
196 \end{document}
197 %</driver>
198 % \fi
199 %
200 % \CheckSum{0}
201 %
202 % \CharacterTable {Upper-case
203 % \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z Lower-case
204 % \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z Digits
205 % \0\1\2\3\4\5\6\7\8\9 Exclamation \! Double quote \" Hash (number)
206 % \# Dollar \$ Percent \% Ampersand \& Acute accent \' Left paren
207 % \( Right paren \) Asterisk \* Plus \+ Comma \, Minus \- Point \.
208 % Solidus \/ Colon \: Semicolon \; Less than \< Equals \= Greater than
209 % \> Question mark \?
210 % Commercial at \@ Left bracket \[ Backslash \\
211 % Right bracket \] Circumflex \^ Underscore \_ Grave accent \` Left
212 % brace \{ Vertical bar \| Right brace \} Tilde \~}
213 %
214 % \DoNotIndex{\newcommand,\newenvironment}
215 %
216 % \begin{macro}
217 % Set up kvoptions
218 % \begin{macrocode}
219 \RequirePackage{kvoptions}
220 \RequirePackage{xifthen}
221
222 \SetupKeyvalOptions{ family=cs,
223 prefix=cs@ }
224 \DeclareStringOption[4]{columns}
225 %Make twocoloumn __not__ be passed to article
226 \DeclareVoidOption{twocolumn}{\ClassError{CheatSheet}{'twocolumn' is not
227 supported, use 'columns=2' instead!}{Because I can not 'catch' an
228 option, I have to emit an Error; if article gets the option
229 'twocolumn', the whole layout will be corrupted!}}
230 % \end{macrocode}
231 % \end{macro}
232 % \begin{macro}
233 % Redefine the article-options
234 % \begin{macrocode}
235 \DeclareDefaultOption{\PassOptionsToClass{\CurrentOptionKey}{article}}
236 % \end{macrocode}
237 %
238 % Processes the Options and loads article
239 % \begin{macrocode}
240 \ProcessKeyvalOptions*
241
242
243
244 %\ifcs@twocolumn
245 %\ifthenelse{\equal{\cs@columns}{2}}{
246 % \ClassWarning{CheatSheet}{You passed
247 % 'twocoloumn' and 'columns=2', please use *only* 'columns=N' (where
248 % is the number of columns you desire), to avoid option clashes!}
249 %}{
250 % \ifthenelse{\equal{\cs@columns}{4}}{
251 % \ClassWarning{CheatSheet}{You passed 'twocoloumn', but 'columns' is set to 4 (the default value),
252 % please use 'columns=2' instead of 'twocoloumn'}
253 % \renewcommand{\cs@columns}{1}
254 % }{
255 % \ClassError{CheatSheet}{Option clash}{You passed
256 % 'twocoloumn', but 'columns' is set to \cs@columns}
257 % }
258 %}
259 %\fi
260
261 \LoadClass{article}
262 % \end{macrocode}
263 % Loads required Packages
264 % \begin{macrocode}
265 \PassOptionsToPackage{T1}{fontenc}
266 \RequirePackage{hyperref}
267 \RequirePackage{fontenc}
268 \RequirePackage{libertine}
269 \RequirePackage{suffix}
270 \PassOptionsToPackage{fleqn}{amsmath}
271 \RequirePackage{amsmath}
272 \RequirePackage{amssymb}
273 \RequirePackage{multicol}
274 \PassOptionsToPackage{autostyle,german=guillemets}{csquotes}
275 \RequirePackage{csquotes}
276
277 \RequirePackage{xcolor}
278 \definecolor{primaryColor}{cmyk}{1,.72,0,.38}
279 \definecolor{secondaryColor}{named}{gray}
280
281 \RequirePackage{mdframed}
282
283
284 \RequirePackage{listings}
285 \lstset{
286 breaklines = true,
287 postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow\space}},
288 basicstyle=\ttfamily\color{primaryColor}\scriptsize
289 }
290 \RequirePackage{etoolbox}
291 % \end{macrocode}
292 % \begin{macro}
293 % Turn off headers, pagenumbers, and sectionnumbers. Set |parindent|
294 % and |parskip|
295 % \begin{macrocode}
296 \pagestyle{empty}
297 \setcounter{secnumdepth}{0}
298 \setlength{\parindent}{0pt}
299 \setlength{\parskip}{0pt plus 0.5ex}
300 % \end{macrocode}
301 % \end{macro}
302 % Redefine document, so that it is always multicolumn
303 % \begin{macro}
304 % \begin{macrocode}
305 \AtBeginDocument{%\bgroup % POSSIBLY BUG FIX:Include this command if
306 % you should ever encounter the later error
307 % at the first time of compilation (with
308 % removed .aux)
309 %! LaTeX Error: Can be used only in preamble.
310 %See the LaTeX manual or LaTeX Companion for explanation.
311 %Type H <return> for immediate help.
312 %...
313 %
314 %l.6 \HyperFirstAtBeginDocument
315 % {\ifx\hyper@anchor\@undefined
316 \begin{multicols}{\cs@columns}}
317 \AtEndEnvironment{document}{\end{multicols}}
318 % \end{macrocode}
319 % \end{macro}
320 % \begin{macro}
321 % Set Font size
322 % \begin{macrocode}
323 \AtBeginDocument{
324 \raggedright
325 %footnotesize
326 }
327 % \end{macrocode}
328 % \end{macro}
329 % \begin{macro}
330 % Make sure that this is the last Package loaded
331 % \begin{macrocode}
332 %Make sure that this is the last Package loaded
333 \RequirePackage{geometry}
334 \geometry{top=1cm, bottom=1cm, left=1cm,
335 headsep=14pt,hmarginratio={1:1}}
336 % \end{macrocode}
337 % \end{macro}
338 % \subsection{Translations\label{imp:translation}}
339 % Load translations, currently supports English and German, Fallback
340 % is German
341 % \begin{macrocode}
342 % \end{macrocode}
343 % \section{Redefinition of existing Commands}
344 % \begin{macro}
345 % Displays equation-numbers as upper-case roman numbers.
346 % \begin{macrocode}
347 \renewcommand{\theequation}{\Roman{equation}}
348 % \end{macrocode}
349 % \end{macro}
350 % \begin{macro}
351 % Colors Headings and math
352 % \begin{macrocode}
353 \everymath\expandafter{\the\everymath \color{primaryColor}}
354 % \end{macrocode}
355 % \end{macro}
356 % \begin{macro}[\maketitle]
357 % \begin{macrocode}
358 \renewcommand{\title}[1]{
359 \def\thetitle{#1}
360 }
361
362 \renewcommand{\date}[1]{
363 \def\thedate{#1}
364 }
365 \renewcommand{\author}[1]{
366 \def\theauthor{#1}
367 }
368
369 \renewcommand{\maketitle}{
370 \begin{mdframed}[
371 linecolor=secondaryColor,linewidth=1pt,%
372 leftmargin=0mm,rightmargin=0mm,skipbelow=0mm,skipabove=0mm
373 ]
374 {\color{primaryColor}\Large\textbf\sffamily\thetitle}\\
375 \normalsize\theauthor\\
376 \normalsize\thedate\\
377 \end{mdframed}
378
379 {\color{secondaryColor} \rule{\linewidth}{1pt}}
380 }
381 % \end{macrocode}
382 % \end{macro}
383 % \begin{macro}[Sectioning]
384 % \begin{macrocode}
385 \renewcommand{\section}{\@startsection{section}{1}{0mm}%
386 {-1ex plus -.5ex minus -.2ex}%
387 {0.5ex plus .2ex}%x
388 {\normalfont\large\bfseries\sffamily\color{primaryColor}}}
389 \renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
390 {-1explus -.5ex minus -.2ex}%
391 {0.5ex plus .2ex}%
392 {\normalfont\normalsize\sffamily\bfseries}}
393 \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
394 {-1ex plus -.5ex minus -.2ex}%
395 {1ex plus .2ex}%
396 {\normalfont\small\sffamily}}
397 % \end{macrocode}
398 % \end{macro}
399 % \textit{The End}
400 % \begin{macrocode}
401 \endinput
402 % \end{macrocode}