diff options
author | Karl Berry <karl@freefriends.org> | 2020-01-09 22:12:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-01-09 22:12:42 +0000 |
commit | 5a49a16364de5bdb0b342263c630719965ca6f89 (patch) | |
tree | f4b36e642899f434bac3a9292a6d1161862f7324 /Master | |
parent | 549247b6ff6c51c2403214da644afd565bfda9ba (diff) |
circledsteps (9jan20)
git-svn-id: svn://tug.org/texlive/trunk@53356 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.pdf | bin | 337762 -> 404870 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.tex | 90 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/circledsteps/circledsteps.sty | 60 |
3 files changed, 112 insertions, 38 deletions
diff --git a/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.pdf b/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.pdf Binary files differindex ae0581a6443..e7b54234b39 100644 --- a/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.pdf +++ b/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.pdf diff --git a/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.tex b/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.tex index c98ab46e4ce..4867907abfa 100644 --- a/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.tex +++ b/Master/texmf-dist/doc/latex/circledsteps/circledsteps-manual.tex @@ -16,10 +16,10 @@ urlcolor=blue, % color of external links } \usepackage{showexpl} -\lstset{pos=t, overhang=0pt,hsep=\columnsep,vsep=\bigskipamount, +\lstset{pos=l, overhang=0pt,hsep=\columnsep,vsep=\bigskipamount, rframe=single,numbers=left,numberstyle=\tiny,numbersep=.3em, xleftmargin=1em, columns=flexible, language=[LaTeX]TEX,breaklines=true, - basicstyle=\small\ttfamily,tabsize=3, varwidth} + basicstyle=\small\ttfamily,tabsize=3, width=0.4\linewidth} \usepackage{circledsteps} \title{The \texttt{circledsteps} package: circled numbers, circled steps and more} @@ -36,20 +36,37 @@ This package was born thanks to the discussion on \href{https://tex.stackexchang 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. +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. + +The manual is for version~\cstepsversion. The main changes between version are listed below. +\begin{description} + \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. + + Added \texttt{fill color} for the circles background. + \item[v1.1] Default to normal colors; keep the ``red/blue'' theme as optional. + If you use the package option \texttt{redblue} or \texttt{legacy} you will have the same effect than + \begin{lstlisting}[] + \pgfkeys{/csteps/inner color=red, /csteps/outer color=blue} + \end{lstlisting} + \item[v1.0] Initial release. +\end{description} + + \section{Basic commands} The basic commands are: \begin{tabular}{>{\ttfamily\textbackslash}ll} \toprule - Circled\{\} & circled text using the package colors, text on the baseline\\ - CircledTop\{\} & circled text using the package colors, circle on the baseline\\ - CircledText\{\} & circled text using the current color (may fail\footnotemark{} across pages break in header or footers)\\ + Circled[]\{\} & circled text using the package colors, text on the baseline\\ + CircledTop[]\{\} & circled text using the package colors, circle on the baseline\\ + CircledText[]\{\} & circled text using the current color\footnotemark{}\\ \bottomrule \end{tabular} -\footnotetext{in the sense it can select the wrong color.} +\footnotetext{it may fail when used in headers or footers, in the sense it can select the wrong color in case of page breaks.} + +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. -The parameters for the output are controlled using \texttt{pgfkeys}; you can change them with \verb|\tikzset|; you can obviously limit the effect of change using normal \LaTeX{} scoping rules. The pseudo-color \texttt{none} means that the current color is used for both the text and the circle. \begin{tabular}{>{\ttfamily}lll} @@ -60,15 +77,18 @@ The pseudo-color \texttt{none} means that the current color is used for both the /csteps/inner xsep & horizontal spacing & 4pt\\ /csteps/inner color & color of the text & none\\ /csteps/outer color & color of the circle & none\\ + /csteps/fill color & background color of the circle & none\\ \bottomrule \end{tabular} -The working of the package is better explained with examples. +The usage of the package is better explained with examples. -\begin{LTXexample} -This is normal text: \Circled{1} is on the baseline, \CircledTop{2} is on top. -This is more evident if you have descendents, like p:\Circled{p} and \CircledTop{p}. +\begin{LTXexample} +This is normal text: \Circled{1} is on the baseline, \CircledTop{2} is on top.\par +This is more evident if you have descendents, like p: \Circled{p} and \CircledTop{p}.\par +You can set options as optional arguments, like \Circled[inner color=red]{R} or \CircledTop[outer color=green]{g}.\par +Math mode is detected too: \Circled{A} and $\Circled{A}^{\Circled{A}}$. \end{LTXexample} @@ -80,52 +100,68 @@ For big horizontal things the circle becomes oval: \Circled{200} or \CircledTop{ \begin{LTXexample} Inside \texttt{tikz} they work ok: +\tikzset{/csteps/outer color=green!30!black} \begin{tikzpicture}[scale=0.8, rotate=30, text width=3cm, transform shape] - \node [draw,color=purple]{text \Circled{1}}; + \node [draw,color=purple]{text \Circled{1} + \Circled[inner color=blue]{2}}; \end{tikzpicture} \end{LTXexample} \begin{LTXexample} -\tikzset{/csteps/inner ysep=10pt} -\tikzset{/csteps/inner xsep=10pt} +\pgfkeys{/csteps/inner ysep=10pt} +\pgfkeys{/csteps/inner xsep=10pt} If you like more breathing space: \Circled{1} \Circled{2} \Circled{p} \Circled{200} \Circled{199}. \par\bigskip \end{LTXexample} \begin{LTXexample} -\tikzset{/csteps/inner color=green} -\tikzset{/csteps/outer color=gray} +\pgfkeys{/csteps/inner color=green} +\pgfkeys{/csteps/outer color=gray} If you want to change colors it's easy: \Circled{1} \Circled{2} \Circled{p} \Circled{200} \Circled{199}. \par\bigskip \end{LTXexample} -If you use the package option \texttt{redblue} or \texttt{legacy} you will have the same effect than +\begin{LTXexample} +\pgfkeys{/csteps/inner color=white} +\pgfkeys{/csteps/outer color=red} +\pgfkeys{/csteps/fill color=black} +And you can have filled circles and ovals: +\Circled{\textbf{1}} \Circled{\textbf{199}}. +\par\bigskip +\end{LTXexample} -\begin{lstlisting}[] - \tikzset{/csteps/inner color=red, /csteps/outer color=blue} -\end{lstlisting} \begin{LTXexample} -Or even you can have inline numbers like \CircledText{1} or +You can have inline numbers like \CircledText{1} or exponents\textsuperscript{\CircledText{2}} and so on. \textcolor{red}{They follow the current color: \CircledText{1} and \CircledText{2} automatically,} as you can see: \CircledText{$1+1\approx3$}. In-text circled numbers look better when a bit smaller, though, as you can see in {\small\CircledText{1}} for example. \end{LTXexample} -No, you can't fill the circle/oval. Pull requests in that sense are welcome. +You can have also quite nice math mode effects, thanks to suggestion from \texttt{@tallmarmot}: + +\begin{LTXexample} + \[\Circled[outer color=red]{x}\] + \[\int\limits_{-1}^1\!\mathrm{d}x\,f_{\ell_1}(x)\] + \[\Circled[outer color=blue]{\int\limits_{-1}^1}\! + \Circled[outer color=orange]{\mathrm{d}x} + f_{\Circled[outer color=red]{\ell}_{\Circled[outer color=cyan]{1}}}(x)\] +\end{LTXexample} + \section{Automatically generated numbers} -The command \verb|\cstep| will generate a circled number, starting from \texttt{1}, that can be referenced with the normal \verb|\label| mechanism. You can reset the numbering with +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 one the right are blue to to \texttt{hyperref} configuration!} You can reset the numbering with \verb|\startcstep|. For example: \input{ctikzexample.tex} \lstinputlisting{ctikzexample.tex} + \bigskip \section{Personalize it!} @@ -133,14 +169,12 @@ The command \verb|\cstep| will generate a circled number, starting from \texttt{ 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!): \begin{lstlisting} -\newcommand{\CircledText}[1]{% - \begingroup - \tikzset{/csteps/inner color=none, /csteps/outer color=none,} - \Circled{#1}% - \endgroup +\newcommand{\CircledText}[2][]{% + \csteps@CircledParamOpts{inner color=none, outer color=none, #1}{1}{#2}% } \end{lstlisting} +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''. 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): diff --git a/Master/texmf-dist/tex/latex/circledsteps/circledsteps.sty b/Master/texmf-dist/tex/latex/circledsteps/circledsteps.sty index 8949ec71cb3..db49c69cbc7 100644 --- a/Master/texmf-dist/tex/latex/circledsteps/circledsteps.sty +++ b/Master/texmf-dist/tex/latex/circledsteps/circledsteps.sty @@ -1,6 +1,7 @@ % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1996/06/01] -\ProvidesPackage{circledsteps}[2019/11/01 v1.1 Circled steps that you can reference] +\ProvidesPackage{circledsteps}[2020/01/08 v1.2 Circled steps that you can reference] +\def\cstepsversion{v1.2} % \end{macrocode} % % Copyright (c) 2019 Romano Giannetti @@ -12,20 +13,30 @@ \RequirePackage{pict2e} \RequirePackage{picture} \RequirePackage{pgfkeys} % for the pgfkeys +\pgfkeys{/csteps/.is family} \pgfkeys{/csteps/inner ysep/.initial=4pt, /csteps/inner xsep/.initial=4pt, /csteps/inner color/.initial=none, /csteps/outer color/.initial=none, + /csteps/fill color/.initial=none, } \DeclareOption{redblue}{ - \tikzset{/csteps/inner color=red, /csteps/outer color=blue}% + \pgfkeys{/csteps/inner color=red, /csteps/outer color=blue}% } \DeclareOption{legacy}{ - \tikzset{/csteps/inner color=red, /csteps/outer color=blue}% + \pgfkeys{/csteps/inner color=red, /csteps/outer color=blue}% } % end of options definitions \ProcessOptions\relax +% thanks @egreg https://tex.stackexchange.com/a/523450/38080 +\RequirePackage{etoolbox} +\newif\ifcstepsfilledovals\cstepsfilledovalsfalse +\@ifpackageloaded{picture}{\patchcmd\PcOrg@@oval}{\patchcmd\@oval} + {\pIIe@strokeGraph} + {\ifcstepsfilledovals\pIIe@fillGraph\else\pIIe@strokeGraph\fi} + {}{} + \newsavebox\csteps@CBox \newlength\csteps@XLength \newlength\csteps@YLength \newlength\csteps@YDepth \newlength\csteps@tmplen @@ -33,15 +44,21 @@ \edef\csteps@none{none}% \edef\csteps@outercolor{\pgfkeysvalueof{/csteps/outer color}}% \edef\csteps@innercolor{\pgfkeysvalueof{/csteps/inner color}}% + \edef\csteps@fillcolor{\pgfkeysvalueof{/csteps/fill color}}% \csteps@XLength=\wd\csteps@CBox\advance\csteps@XLength by\pgfkeysvalueof{/csteps/inner xsep}\relax \csteps@tmplen=\pgfkeysvalueof{/csteps/inner ysep}\relax \csteps@YDepth=\dp\csteps@CBox\advance\csteps@YDepth by 0.5\csteps@tmplen\relax \csteps@YLength=\ht\csteps@CBox\advance\csteps@YLength by\dp\csteps@CBox\advance\csteps@YLength by\pgfkeysvalueof{/csteps/inner ysep}\relax % \typeout{DBG:#2\space X:\the\csteps@XLength\space Y:\the\csteps@YLength\space D:\the\csteps@YDepth}% + % \typeout{DBG\space inner:\csteps@innercolor\space outer:\csteps@outercolor\space ARG2:#2}% \raisebox{-#1\csteps@YDepth}{% \ifdim\csteps@XLength>\csteps@YLength \makebox[\csteps@XLength]{% X bigger than Y \makebox(0,\csteps@YLength){% + \ifx\csteps@fillcolor\csteps@none\else + \color{\csteps@fillcolor}% + {\cstepsfilledovalstrue\put(0,0){\oval(\csteps@XLength,\csteps@YLength)}}% + \fi \ifx\csteps@outercolor\csteps@none\else \color{\csteps@outercolor}% \fi @@ -49,7 +66,7 @@ }% \makebox(0,\csteps@YLength){% \put(-.5\wd\csteps@CBox,0){% - \ifx\csteps@outercolor\csteps@none + \ifx\csteps@innercolor\csteps@none #2\relax% \else \textcolor{\csteps@innercolor}{#2}% @@ -59,6 +76,10 @@ \else \makebox[\csteps@YLength]{% \makebox(0,\csteps@YLength){% + \ifx\csteps@fillcolor\csteps@none\else + \color{\csteps@fillcolor}% + \put(0,0){\circle*{\csteps@YLength}}% + \fi \ifx\csteps@outercolor\csteps@none\else \color{\csteps@outercolor}% \fi @@ -66,7 +87,7 @@ }% \makebox(0,\csteps@YLength){% \put(-.5\wd\csteps@CBox,0){% - \ifx\csteps@outercolor\csteps@none + \ifx\csteps@innercolor\csteps@none #2\relax% \else \textcolor{\csteps@innercolor}{#2}% @@ -79,14 +100,33 @@ % \end{macrocode} % Main commands: % \begin{macrocode} -\def\Circled#1{\csteps@CircledParam{1}{#1}} -\def\CircledTop#1{\csteps@CircledParam{0}{#1}} -\newcommand{\CircledText}[1]{% +\newcommand{\CircledParamOpts}[3]{% \begingroup - \tikzset{/csteps/inner color=none, /csteps/outer color=none}% - \Circled{#1}% + \pgfkeys{/csteps/.cd, #1}% + \ifmmode + \mathchoice{% + \csteps@CircledParam{#2}{$\displaystyle #3$}% + }% + {% + \csteps@CircledParam{#2}{$\textstyle #3$}% + }% + {% + \csteps@CircledParam{#2}{$\scriptstyle #3$}% + }% + {% + \csteps@CircledParam{#2}{$\scriptscriptstyle #3$}% + }% + \else + \csteps@CircledParam{#2}{#3}% + \fi \endgroup } + +\newcommand{\Circled}[2][]{\CircledParamOpts{#1}{1}{#2}} +\newcommand{\CircledTop}[2][]{\CircledParamOpts{#1}{0}{#2}} +\newcommand{\CircledText}[2][]{% + \CircledParamOpts{inner color=none, outer color=none, #1}{1}{#2}% +} % \end{macrocode} % Automatic counters code % \begin{macrocode} |