Skip to content

Commit

Permalink
Merge pull request #7 from Rmano/filled-circled
Browse files Browse the repository at this point in the history
Added filled circled.
  • Loading branch information
Rmano authored Jan 8, 2020
2 parents 9ad3cba + 413beb2 commit 5d4e781
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
18 changes: 13 additions & 5 deletions circledsteps-manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ \section{Introduction}

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}).
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}[]
Expand Down Expand Up @@ -75,6 +77,7 @@ \section{Basic commands}
/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}

Expand Down Expand Up @@ -122,11 +125,18 @@ \section{Basic commands}
\par\bigskip
\end{LTXexample}


\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{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}
Expand All @@ -142,8 +152,6 @@ \section{Basic commands}
\end{LTXexample}


No, you can't fill the circle/oval. Pull requests in that sense are welcome.

\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|/\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
Expand Down
18 changes: 18 additions & 0 deletions circledsteps.sty
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/csteps/inner xsep/.initial=4pt,
/csteps/inner color/.initial=none,
/csteps/outer color/.initial=none,
/csteps/fill color/.initial=none,
}
\DeclareOption{redblue}{
\pgfkeys{/csteps/inner color=red, /csteps/outer color=blue}%
Expand All @@ -28,13 +29,22 @@

% 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
\def\csteps@CircledParam#1#2{\sbox\csteps@CBox{#2}%
\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
Expand All @@ -45,6 +55,10 @@
\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
Expand All @@ -62,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
Expand Down

0 comments on commit 5d4e781

Please sign in to comment.