Debian Codegraph @

texmf-dist/doc/latex/circledsteps/circledsteps-manual.tex

raw
1 \documentclass{ltxdoc}
2 \usepackage{doc}
3 \usepackage[T1]{fontenc}
4 \usepackage[utf8]{inputenc}
5 \usepackage{a4wide}
6 \usepackage{tikz}
7 \usepackage[siunitx, RPvoltages]{circuitikz}
8 \ctikzset{%
9 american,
10 cute inductors,
11 }
12 \usepackage{booktabs}
13 \usepackage{showexpl}
14 \usepackage{accsupp} % Thanks to Ulrike Fischer https://tex.stackexchange.com/a/57160/38080
15 \newcommand{\emptyaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}%
16 \lstset{explpreset={pos=l, overhang=0pt,hsep=\columnsep,vsep=\bigskipamount,
17 rframe=single,numbers=left,numberstyle=\tiny,numbersep=.3em, xleftmargin=1em,
18 columns=flexible, language=[LaTeX]TEX,breaklines=true,
19 basicstyle=\small\ttfamily,tabsize=3, width=0.4\linewidth,
20 numberstyle=\tiny\color{gray}\emptyaccsupp}}
21 % there must be a better way
22 \lstset{pos=l, overhang=0pt,hsep=\columnsep,vsep=\bigskipamount,
23 rframe=single,numbers=left,numberstyle=\tiny,numbersep=.3em, xleftmargin=1em,
24 columns=flexible, language=[LaTeX]TEX,breaklines=true,
25 basicstyle=\small\ttfamily,tabsize=3, width=0.4\linewidth,
26 numberstyle=\tiny\color{gray}\emptyaccsupp}
27 \usepackage{circledsteps}
28 \usepackage{hyperref}
29 \hypersetup{colorlinks=true, % false: boxed links; true: colored links
30 linkcolor=blue, % color of internal links
31 urlcolor=blue, % color of external links
32 }
33
34 \title{The \texttt{circledsteps} package: circled numbers, circled steps and more}
35 \author{Romano Giannetti <[email protected]>}
36 % when we have lot of insets, this is better:
37 \parindent=0pt\parskip=6pt plus 6pt minus 2pt\relax
38
39 \begin{document}
40 \maketitle
41
42 \section{Introduction}
43
44 This package was born thanks to the discussion on \href{https://tex.stackexchange.com/questions/7032/good-way-to-make-textcircled-numbers}{tex.stackexchange.com}, and with the help of the several authors that contributed to the answers. The base idea is to have a command that can create arbitrary ``circled'' text (numbers or letters) and that can work in normal text \textbf{and} in a node in a \texttt{tikzpicure} or derivative. That forbid to use \texttt{Ti\emph{k}Z} itself for the circles --- you can't safely nest \texttt{tikzpicture}s.
45
46 This package provides two things: the first one, macros to generate the circled text that use the original \texttt{pict2e} method, and then a (simple, to be taken as an example) set of macro to generate sequential circled numbers that can be referenced afterward.
47
48 The package loads (if not already loaded) the packages \texttt{pict2e}, \texttt{pictures}, \texttt{xcolor} and \texttt{pgfkeys} (the latter one is automatically loaded by \texttt{tikz}; you do not need \texttt{tikz} to use just \texttt{circledsteps}). Moreover, \texttt{etoolbox} is loaded to modify \texttt{pict2e} to have filled ovals.
49
50 The manual is for version~\cstepsversion. The main changes between version are listed below.
51 \begin{description}
52 \item[v1.3.x] Fixes to the manual; added a warning in case the patching of \texttt{pict2e.sty} fails.
53 \item[v1.2] Added optional argument to the commands and make them sensitive to math mode (thanks to \texttt{@tallmarmot} for the suggestion and example code); fixed several bugs.
54
55 Added \texttt{fill color} for the circles background.
56 \item[v1.1] Default to normal colors; keep the ``red/blue'' theme as optional.
57 If you use the package option \texttt{redblue} or \texttt{legacy} you will have the same effect than
58 \begin{lstlisting}
59 \pgfkeys{/csteps/inner color=red, /csteps/outer color=blue}
60 \end{lstlisting}
61 \item[v1.0] Initial release.
62 \end{description}
63
64
65 \section{Basic commands}
66
67 The basic commands are:
68
69 \begin{tabular}{>{\ttfamily\textbackslash}ll}
70 \toprule
71 Circled[]\{\} & circled text using the package colors, text on the baseline\\
72 CircledTop[]\{\} & circled text using the package colors, circle on the baseline\\
73 CircledText[]\{\} & circled text using the current color\footnotemark{}\\
74 \bottomrule
75 \end{tabular}
76 \footnotetext{it may fail when used in headers or footers, in the sense it can select the wrong color in case of page breaks.}
77
78 The parameters for the output are controlled using \texttt{pgfkeys}; you can change them with \verb|\pgfkeys| or \verb|\tikzset|; you can obviously limit the effect of change using normal \LaTeX{} scoping rules. Also, you can specify parameters (without the initial \texttt{/csteps/} as optional arguments to the commands.
79
80 The pseudo-color \texttt{none} means that the current color is used for both the text and the circle.
81
82 \begin{tabular}{>{\ttfamily}lll}
83 \toprule
84 \textbf{Parameter} & \textbf{Meaning} & \textbf{Default value} \\
85 \midrule
86 /csteps/inner ysep & vertical spacing & 4pt\\
87 /csteps/inner xsep & horizontal spacing & 4pt\\
88 /csteps/inner color & color of the text & none\\
89 /csteps/outer color & color of the circle & none\\
90 /csteps/fill color & background color of the circle & none\\
91 \bottomrule
92 \end{tabular}
93
94 The usage of the package is better explained with examples.
95
96
97 \begin{LTXexample}
98 This is normal text: \Circled{1} is on the
99 baseline, \CircledTop{2} is on top.
100
101 This is more evident if you have descenders,
102 like p: \Circled{p} and \CircledTop{p}.
103
104 You can set options as optional arguments,
105 like \Circled[inner color=red]{R} or
106 \CircledTop[outer color=green]{g}.
107
108 Math mode is detected too: \Circled{A}
109 and $\Circled{A}^{\Circled{A}}$.
110 \end{LTXexample}
111
112
113 \begin{LTXexample}
114 For big horizontal things the circle becomes
115 oval: \Circled{200} or \CircledTop{199}.
116 \end{LTXexample}
117
118
119 \begin{LTXexample}
120 Inside \texttt{tikz} they work ok:
121
122 \tikzset{/csteps/outer color=green!30!black}
123 \begin{tikzpicture}[scale=0.8, rotate=30,
124 text width=3cm, transform shape]
125 \node [draw,color=purple]{text \Circled{1}
126 \Circled[inner color=blue]{2}};
127 \end{tikzpicture}
128 \end{LTXexample}
129
130
131 \begin{LTXexample}
132 \pgfkeys{/csteps/inner ysep=10pt}
133 \pgfkeys{/csteps/inner xsep=10pt}
134 If you like more breathing space:
135 \Circled{1} \Circled{2} \Circled{p}
136 \Circled{200} \Circled{199}.
137 \end{LTXexample}
138
139 \begin{LTXexample}
140 \pgfkeys{/csteps/inner color=green!50!black}
141 \pgfkeys{/csteps/outer color=gray}
142 If you want to change colors it's easy:
143 \Circled{1} \Circled{2} \Circled{p}
144 \Circled{200} \Circled{199}.
145 \end{LTXexample}
146
147 \begin{LTXexample}
148 \pgfkeys{/csteps/inner color=yellow}
149 \pgfkeys{/csteps/outer color=red}
150 \pgfkeys{/csteps/fill color=black}
151 And you can have filled circles and ovals:
152 \Circled{\textbf{1}} \Circled{\textbf{199}}.
153 \end{LTXexample}
154
155
156 \begin{LTXexample}
157 You can have inline numbers like \CircledText{1}
158 or exponents\textsuperscript{\CircledText{2}}
159 and so on.
160 \textcolor{red}{They follow the current color:
161 \CircledText{1} and \CircledText{2}
162 automatically,} as you can see here:
163 \CircledText{$1+1\approx3$}.
164 In-text circled numbers look better when
165 they are a bit smaller, though, as you
166 can see in {\small\CircledText{1}}
167 for example.
168 \end{LTXexample}
169
170 You can have also quite nice math mode effects, thanks to suggestion from \texttt{@tallmarmot}:
171
172 \begin{LTXexample}
173 \[\Circled[outer color=red]{x}\]
174 \[\int\limits_{-1}^1\!
175 \mathrm{d}x\,f_{\ell_1}(x)\]
176 \[\Circled[outer color=blue]{%
177 \int\limits_{-1}^1}\!
178 \Circled[outer color=orange]{\mathrm{d}x}
179 f_{\Circled[outer color=red]{\ell}_{%
180 \Circled[outer color=cyan]{1}}}(x)\]
181 \end{LTXexample}
182
183
184 \section{Automatically generated numbers}
185
186 The command \verb|\cstep| will generate a circled number, starting from \texttt{1}, that can be referenced with the normal \verb|\label|/\verb|\ref| mechanism.\footnote{Notice that in the example the numbers in the references on the right are blue due to \texttt{hyperref} configuration!} You can reset the numbering with
187 \verb|\startcstep|. For example:
188
189 \input{ctikzexample.tex}
190
191 \lstinputlisting{ctikzexample.tex}
192
193
194 \bigskip
195
196 \section{Personalize it!}
197
198 The definition of \verb|CircledTexT| is simply the following one; you can get idea and define your own easily (beware of spaces at the end of the lines, though!):
199
200 \begin{lstlisting}
201 \newcommand{\CircledText}[2][]{%
202 \CircledParamOpts{inner color=none, outer color=none, #1}{1}{#2}%
203 }
204 \end{lstlisting}
205
206 where \verb|\CircledParamOpts| is a macro with three arguments: the first one is the list of options (without the \texttt{/csteps/} part), the second one is 1 is you want the circle content on the baseline and 0 if you want it on top of it, and finally the third one is the text to be ``circled''.
207
208 Also the implementation of the \verb|\cstep| command and relatives is quite simple, and you can play a lot with it to change things (formats, colors, the type of numbering, and so on):
209
210 \begin{lstlisting}
211 \newcounter{cstepcnt}
212 \newcommand{\startcstep}{\setcounter{cstepcnt}{0}}
213 \newcommand{\resetcstep}{\setcounter{cstepcnt}{0}}
214 \newcommand{\cstep}{%
215 \refstepcounter{cstepcnt}%
216 \Circled{\scriptsize\arabic{cstepcnt}}%
217 }
218 \renewcommand{\thecstepcnt}{\arabic{cstepcnt}}
219 \end{lstlisting}
220
221
222 \end{document}