Debian Codegraph @

texmf-dist/tex/lualatex/pdfarticle/pdfArticle.cls

raw
1 % Copyright (c) 2015-2019 Robert Ryszard Paciorek <[email protected]>
2 %
3 % MIT License
4 %
5 % Permission is hereby granted, free of charge, to any person obtaining a copy
6 % of this software and associated documentation files (the "Software"), to deal
7 % in the Software without restriction, including without limitation the rights
8 % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 % copies of the Software, and to permit persons to whom the Software is
10 % furnished to do so, subject to the following conditions:
11 %
12 % The above copyright notice and this permission notice shall be included in all
13 % copies or substantial portions of the Software.
14 %
15 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 % SOFTWARE.
22
23 \NeedsTeXFormat{LaTeX2e}
24 \ProvidesClass{pdfArticle}[2019/05/01 v1.0 simple class for creating PDF documents with LuaLaTeX]
25
26 \RequirePackage{kvoptions} % key=value option for class ... use also by hyperref, so zero overhead
27 \SetupKeyvalOptions{family=KVP, prefix=KVP@} % KVP = Key Val Parameters
28
29 % Fonts settings
30 \DeclareStringOption[11pt] {fontSize} % base size of font (8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, or 20pt with extarticle document class)
31 \DeclareStringOption[
32 UprightFeatures = { SmallCapsFont={ lmromancaps10regular } },
33 ItalicFeatures = { SmallCapsFont={ lmromancaps10oblique } },
34 SlantedFont = lmromanslant10regular,
35 BoldSlantedFont = lmromanslant10bold,
36 Ligatures=TeX
37 ] {mainFontFeat} % features settings for mainFont
38 \DeclareStringOption[Latin Modern Roman] {mainFont} % document default main (serif) fornt
39 \DeclareStringOption[
40 Ligatures=TeX
41 ] {sansFontFeat} % features settings for sansFont
42 \DeclareStringOption[Latin Modern Sans] {sansFont} % document default main sans-serif fornt
43 \DeclareStringOption[
44 UprightFeatures = { SmallCapsFont={ lmmonocaps10regular } },
45 ItalicFont = lmmono10italic,
46 ItalicFeatures = { SmallCapsFont={ lmmonocaps10oblique } },
47 SlantedFont = lmmonoslant10regular
48 ] {monoFontFeat} % features settings for monoFont
49 \DeclareStringOption[Latin Modern Mono Light] {monoFont} % document default main mono-space fornt
50
51 % Paper settings
52 \DeclareStringOption[a4paper] {paperSize} % paper size
53 \DeclareStringOption[portrait] {paperMode} % paper orientation: portrait lub landscape
54 \DeclareStringOption[2.2cm] {tmargin} % top margin size
55 \DeclareStringOption[2.5cm] {bmargin} % bottom margin size
56 \DeclareStringOption[2.2cm] {lmargin} % left margin size
57 \DeclareStringOption[2.2cm] {rmargin} % right margin size
58 \DeclareBoolOption [true] {twoside} % two side mode (switch left/right margin size): true lub false
59
60 % Other settings
61 \DeclareStringOption[150] {imgResolution} % default resolution (ppi) for raster images inserted into PDF files (override by file header info)
62 \DeclareBoolOption [false] {extra} % enable load extra package set
63
64 \ProcessKeyvalOptions*
65
66 % disable automatic convert eps -> pdf
67 \def\DoNotLoadEpstopdf{\relax}
68
69 % use extarticle as base class
70 \LoadClass[\KVP@fontSize]{extarticle}
71
72 % advanced fonts for LuaLaTeX
73 \RequirePackage{fontspec}
74 \defaultfontfeatures[\rmfamily,\sffamily, \ttfamily]{}
75 \setmainfont{\KVP@mainFont}[\KVP@mainFontFeat]
76 \setsansfont{\KVP@sansFont}[\KVP@sansFontFeat]
77 \setmonofont{\KVP@monoFont}[\KVP@monoFontFeat]
78
79 % insert images, with extended key=value interface ... set some defaults
80 \RequirePackage{graphicx, graphbox}
81 \DeclareGraphicsExtensions{.mp, .pdf, .png, .jpg, .jpeg}
82 \pdfvariable imageresolution \KVP@imgResolution
83
84 % foreground and background colours ... use stack of colors
85 \RequirePackage{xcolor, fifo-stack}
86 \FSCreate{colors}{black}
87
88 % page size and settings
89 \RequirePackage{geometry}
90 \geometry{
91 \KVP@paperSize, \KVP@paperMode,
92 tmargin=\KVP@tmargin, bmargin=\KVP@bmargin, lmargin=\KVP@lmargin, rmargin=\KVP@rmargin
93 }
94 \ifKVP@twoside \geometry{twoside=true} \else \geometry{twoside=false} \fi
95
96 % command for enforce new page geometry inside document, in contrast to \newgeometry:
97 % * allow chage paper size and orientation (only pdf output)
98 % * don't reset current settings (but allow modifies it)
99 \newcommand{\forceNewPageGeometry}[1]{%
100 \clearpage%
101 \Gm@clean\setkeys{Gm}{#1}\Gm@process%
102 \eject \pagewidth=\paperwidth \pageheight=\paperheight%
103 \Gm@changelayout%
104 \ifdefined\headwidth\headwidth=\textwidth\fi%
105 }
106
107 % better verbatim environment ... replace standard verbatim environment by fancyvrb package
108 \RequirePackage{fancyvrb, fvextra}
109 \DefineVerbatimEnvironment{verbatim}{Verbatim}{}
110 \let\verb\Verb
111 \fvset{breaklines=true, breakafter={/-}, breakaftersymbolpre={}, breakaftersymbolpost={\tiny\ensuremath{\ \hookrightarrow\ }}}
112
113 % text decorations (under line, striking out, highlight, contours, shadows, ...)
114 \RequirePackage[normalem]{ulem}
115 \newcommand{\ul}[1][blue]{\bgroup\markoverwith{\textcolor{#1}{\rule[-0.6ex]{2pt}{0.17ex}}}\ULon}
116 \newcommand{\st}[1][red]{\bgroup\markoverwith{\textcolor{#1}{\rule[0.5ex]{2pt}{0.25ex}}}\ULon}
117 \newcommand{\hl}[1][yellow]{\bgroup\markoverwith{\textcolor{#1}{\rule[-0.6ex]{1.02pt}{2.7ex}}}\ULon}
118 \RequirePackage{contour, shadowtext}
119
120 % items lists
121 \RequirePackage{enumitem} % better enumerate, itemize and description environments
122 \RequirePackage{alphalph} % use display counters as letters with support for big numbers (as: ... x, y, z, aa, ab, ac, ...)
123 \let\alph\relax \def\alph#1{\alphalph{\value{#1}}}
124 \let\Alph\relax \def\Alph#1{\AlphAlph{\value{#1}}}
125
126 % other useful stuff ...
127 \RequirePackage{pbox,varwidth} % vertical box with automatic minimal width
128 \RequirePackage{overpic} % put LaTeX stuff on images
129 \RequirePackage{wrapfig} % wrapfigure and wraptable environments for wraping text around images, tables, etc
130 \RequirePackage{array,dcolumn} % extentions for tables
131 \RequirePackage{tabto} % tabbing to fixed positions
132 \RequirePackage{changepage} % for adjustwidth environment
133 \RequirePackage{ragged2e} % \justifying command, justify environment and alternative left, center and right ragged text
134 \RequirePackage{setspace} % set line stretch with \setstretch{} command (it's more powerful way than \linespread{}\selectfont or manualy set \baselineskip)
135 \RequirePackage{amsmath,unicode-math} % math with unicode open-type fonts
136 \RequirePackage{adjustbox} % scale, clip, rotate, etc boxes
137
138 \ifKVP@extra
139 \typeout{Document class "pdfArticle" starting to load "EXTRA" packages ...}\typeout{}
140 \RequirePackage{minted} % nice code highlight (use minted insted of listings, due to encoding problems in listings)
141 % \ifnum\pdf@shellescape=1 \RequirePackage{minted} \else \typeout{}\typeout{Warning: No -shell-escape, so DO NOT use minted package.} \fi
142 \RequirePackage[many,vignette,minted,magazine,poster,external]{tcolorbox} % nice framed boxes
143 \fi
144
145 % if \pdfArticlePreHyperRef is defined run it before load hyperref, but after load all other packages
146 % (for loading packages and do other stuff than should be do before load hyperref)
147 \ifdefined\pdfArticlePreHyperRef\pdfArticlePreHyperRef\fi
148
149 % internal and external links ... use curent color from stack for refernces
150 \RequirePackage[unicode=true, colorlinks=true, linkcolor=black, urlcolor=blue]{hyperref}
151 \let\oldref\ref
152 \AtBeginDocument{\renewcommand\ref[1]{\hyperref[#1]{\color{\FSTop{colors}}\oldref*{#1}}}}
153
154 % create label with explicit provided name; usage: \namedLabel{label}{name}
155 \newcommand\namedLabel[2]{\begingroup%
156 \let\@currentlabel\@currentlabelx%
157 \def\@currentlabel{#2}%
158 \label{#1}%
159 \let\@currentlabelx\@currentlabel%
160 \endgroup}
161
162 \typeout{Loading document class "pdfArticle" completed!}\typeout{}