Debian Codegraph @

texmf-dist/doc/latex/easyformat/easyformat.tex

raw
1 % !TeX spellcheck = en_GB
2
3 \documentclass[11pt, cm-default]{l3doc}
4 % 11pt and keep on using the Computer Modern.
5 % We want to maintain the original look of
6 % our documentation so away with the coloured
7 % links and references as wel ↓↓↓
8 \hypersetup{hidelinks}
9
10 \usepackage[british]{babel}
11 \usepackage{microtype}
12 \usepackage{easyformat}
13
14 \def\labelitemi{--}
15
16 \title{\pkg{easyformat}\\[.5em]
17 \large _the_ manual for the 2017/06/03 version (v1.4.0)}
18
19 \author{Evert Provoost}
20
21 \date{}
22
23 \begin{document}
24
25 \maketitle
26
27 \begin{abstract}
28 \pkg{easyformat} is a package that allows the use of~|_| to begin/end _italics_ or __boldface__ and |^| to begin/end ^smallcaps^. As an alternative to the standard \LaTeX\ |\textit{italic}|, |\textbf{bold}| and |\textsc{smallcaps}|.
29 \end{abstract}
30
31 \tableofcontents
32 \newpage
33
34 %% NOT NEEDED.
35 % Insert a blank page.
36 %\null % The page has to contain 'something'.
37 %\thispagestyle{empty} % Hide the pagenumber.
38 %\addtocounter{page}{-1} % So the next doesn't turn 3.
39 %\newpage
40
41 \section{Introduction}
42 Usually when you want to make something _italic_ or __bold__ in \LaTeX\ you insert |\textit{italic}| or |\textbf{bold}| respectively.
43
44 However when writing a book or another text where this formatting is common, this quickly becomes annoying to type.
45
46 \begin{quote}
47 __Quick disclaimer:__\\
48 I'm not saying that the \LaTeX\ way is bad. I just want to explain that it's not ideal under all circumstances.
49 \end{quote}
50
51 Simple markuplanguages (eg. Markdown) have a more elegant solution.
52 If you, for example, wanted to write:
53 \begin{quote}
54 __Stop!__ You _have_ to wait!
55 \end{quote}
56
57 In Markdown, you'd type:
58 \begin{quote}
59 |**Stop!** You *have* to wait!|
60 \end{quote}
61
62 As you can see it's a matter of _wanting_ italic or bold formatting, adding~*'s where needed and done; no (long) macros to type.
63
64 With the help of \pkg{easyformat} we can do something similar, here we get the same result with:
65 \begin{quote}
66 |__Stop!__ You _have_ to wait!|
67 \end{quote}
68
69 (Why underscores? See: \ref{Why?!})\\
70
71 And since it is good practice to add abbreviations using ^smallcaps^, \pkg{easyformat} gives you |^smallcaps^|.
72
73 So:
74 \begin{quote}
75 |^nasa^ and ^esa^ are probably the best known space agencies.|
76 \end{quote}
77
78 Results in:
79 \begin{quote}
80 ^nasa^ and ^esa^ are probably the best known space agencies.
81 \end{quote}
82
83 \section{Usage, syntax and examples}
84 Like usual you import the package with: |\usepackage{easyformat}|
85
86 \pkg{easyformat} makes |_| an active character, however it was already `special' before so you still have to type~|\_| if you want to insert an underscore.
87
88 The same can be said of |^|, however since this one is difficult to add in ordinary \LaTeX, the \pkg{easyformat} package gives you |\cir| to get \cir.
89
90 \newpage
91
92 As already said, \pkg{easyformat} uses a Markdown-like syntax, so:
93
94 \begin{quote}
95 |_italic,_ __bold,__ ___bolditalic___ and ^smallcaps!^|
96 \end{quote}
97
98 Gives:
99 \begin{quote}
100 _italic,_ __bold,__ ___bolditalic___ and ^smallcaps!^
101 \end{quote}
102
103 However we can also do more complex stuff, eg.:
104 \begin{quote}
105 |_Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__|\\
106 |_zet_tim, liefkan.|
107 \end{quote}
108
109 Becomes:
110 \begin{quote}
111 _Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__ _zet_tim, liefkan.
112 \end{quote}
113
114 Those with a good eye might have noticed that \pkg{easyformat} adds italics correction when needed. Just like |\textit{zet}tim| would have.
115
116 \section{Troubleshooting}
117 \pkg{easyformat} tends to conflict with the loading of other packages, therefore you should probably load \pkg{easyformat} last.
118
119 \begin{quotation}
120 ``For some or other reason I get some weird formatting\dots''
121 \end{quotation}
122
123 It could be a bug---in which case I'd love to hear from you (see \ref{contact})---however, you probably forgot to close your formatting somewhere and because of how \pkg{easyformat} works you can get weird results.
124
125 %__Explanation:__ when you start eg. _italics_ with |_|, \pkg{easyformat} remembers the shape (the same is true for ^smallcaps^, when you start __boldface__ it remembers the series) of the font. When you get out of _italics_, it resets the shape (respectively the series) to what it was before the starting the formatting.
126
127
128 %% This is solved in version 2017/04/09 v1.1.0
129 %\subsection{Underscore in subtitles\label{undtitles}}
130 %If you ever try something similar to |\section{__Vectors:__ $\vec{F}_g$}|: \TeX\ will shout at you. Why? I don't really know. However I do know how to fix this. If we want to get the previous example we would use:
131
132 %\begin{quote}
133 % |\setundsub|\\
134 % % Yeah there's a glitch were the first is indented slightly more
135 % % unless there is something before the next lines......
136 % \hspace*{0pt}|\section{$\textbf{Vectors:} \vec{F}_g$}|\\
137 % \hspace*{0pt}|\setundact|
138 %\end{quote}
139
140 %This first resets the |_| character so it can only be used as the start of subscripts; then adds the subtitle and afterwards re-initiates |_| for __bold__ and _italic_. (Obviously the \pkg{easyformat}-syntax does not work _in_ the subtitle, so you'll have to use the \LaTeX-commands.)
141
142 \newpage
143
144 \section{Macros}
145 \subsection{Special characters}
146 \begin{function}{\cir}
147 \begin{syntax}
148 \cs{cir}
149 \end{syntax}
150 Insert a circumflex (\cir) character.
151 \end{function}
152
153 %%\subsection{Fonts}
154 % Removed in v1.4.0
155 %\begin{function}{\nrfamily}
156 % \begin{syntax}
157 % \cs{nrfamily}
158 % \end{syntax}
159 % Reverts the font family to the default.
160 %\end{function}
161
162 % Removed in v1.4.0
163 %\begin{function}{\nrshape}
164 % \begin{syntax}
165 % \cs{nrshape}
166 % \end{syntax}
167 % Reverts the font shape to the default.
168 %\end{function}
169
170 % Removed in v1.4.0
171 %\begin{function}{\nrseries}
172 % \begin{syntax}
173 % \cs{nrseries}
174 % \end{syntax}
175 % Reverts the font series to the default.
176 %\end{function}
177
178 % Removed in v1.4.0
179 %\begin{function}{\setffamily}
180 % \begin{syntax}
181 % \cs{setffamily} \Arg{font family}
182 % \end{syntax}
183 % Quickly change the font family.
184 %\end{function}
185
186 % Removed in v1.4.0
187 %\begin{function}{\setfshape}
188 % \begin{syntax}
189 % \cs{setfshape} \Arg{font shape}
190 % \end{syntax}
191 % Quickly change the font shape.
192 %\end{function}
193
194 % Removed in v1.4.0
195 %\begin{function}{\setfseries}
196 % \begin{syntax}
197 % \cs{setfseries} \Arg{font series}
198 % \end{syntax}
199 % Quickly change the font series.
200 %\end{function}
201
202 \subsection{\pkg{easyformat}-syntax}
203 \begin{function}{\enableeasyformat}
204 \begin{syntax}
205 \cs{enableeasyformat}
206 \end{syntax}
207 Enables the \pkg{easyformat}-syntax.
208 \end{function}
209
210 \begin{function}{\disableeasyformat}
211 \begin{syntax}
212 \cs{disableeasyformat}
213 \end{syntax}
214 Disables the \pkg{easyformat}-syntax.
215 \end{function}
216
217 % Removed in v1.4.0
218 %\begin{function}{\setciract}
219 % \begin{syntax}
220 % \cs{setciract}
221 % \end{syntax}
222 % Sets the catcode of |^| to 13 (active).
223 %\end{function}
224
225 % Removed in v1.4.0
226 %\begin{function}{\setcirsup}
227 % \begin{syntax}
228 % \cs{setcirsup}
229 % \end{syntax}
230 % Sets the catcode of |^| to 7 (superscript).
231 %\end{function}
232
233 % Removed in v1.4.0
234 %\begin{function}{\setundact}
235 % \begin{syntax}
236 % \cs{setundact}
237 % \end{syntax}
238 % Sets the catcode of |_| to 13 (active).
239 %\end{function}
240
241 % Removed in v1.4.0
242 %\begin{function}{\setundsub}
243 % \begin{syntax}
244 % \cs{setundsub}
245 % \end{syntax}
246 % Sets the catcode of |_| to 8 (subscript).
247 %\end{function}
248
249 \section{Technical details}
250 \subsection{Why \texttt{\_} and not *?\label{Why?!}}
251 To make * work we would have to make it an active character, however this would break things like |\section*{Art}|. The~|_| is already protected by \TeX\ because of it's meaning in mathmode. However, it has little to no use in textmode. This is why we can use~|_| for this purpose and not~*.
252
253 \subsection{Does this break mathmode?}
254 No it doesn't. |_| and |^| keep behaving like before in mathmode, their meaning only changes in textmode. (We first check whether we are in mathmode or not and then behave accordingly.)
255
256 \section{Contact\label{contact}}
257 If you want to make suggestions or have any questions whose answer could be included in a future version of this document, you can email to this address: \url{mailto:[email protected]}
258 \newpage
259
260 \section{Changelog}
261 We only include important changes from v1.0.0 onwards, since earlier versions barely worked.
262
263 \subsection*{2017/06/03 v1.4.0}
264 Improved code readability.
265 We now fully use \pkg{expl3}, which eliminates most of the possible future issues with \LaTeX3.
266 Fixed a kerning issue with |\cir| in mathmode.
267 Removed: |\setundact|, |\setundsub|, |\setciract|, |\setcirsup|, |\nrfamily|, |\nrshape|, |\nrseries|, |\setffamily|, |\setfshape| and |\setfseries| as these do not add any value to the package.
268
269 \subsection*{2017/05/28 v1.3.0}
270 Removed forced re-enabling of the \pkg{easyformat}-syntax at the start of the document.
271 Rewritten to use \pkg{expl3}, this makes the code shorter and a future move to \LaTeX3 easier.
272 Fixed an error that could occur with |\cir|.
273 \pkg{easyformat} now also behaves correctly when a fontpackage is loaded.
274
275 \subsection*{2017/04/17 v1.2.0}
276 Improved handling of mixed styles.
277 Added |^smallcaps^| for ^smallcaps^.
278
279 \subsection*{2017/04/09 v1.1.0}
280 Made usage of syntax in |\section{}|, and similar macros, possible. Changed the behaviour so it works more like |\emph{}| (this also simplifies the code).
281
282 \subsection*{2017/04/07 v1.0.0}
283 First stable version.
284
285 % Insert a friendly message :)
286 \vspace*{\fill}\noindent
287 Made with $\heartsuit$ in Berlaar, Belgium.
288 \clearpage
289
290 \end{document}