Skip to content

Commit

Permalink
Fix circled command (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
compor authored Apr 17, 2024
1 parent 57563a7 commit b300c93
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
10 changes: 5 additions & 5 deletions paper.tex
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@
\newunicodechar{α}{\ensuremath{\alpha}}
\newunicodechar{β}{\ensuremath{\beta}}


% \circled command to print a colored circle.
% \circled{1} pretty-prints "(1)"
% This is useful to refer to labels that are embedded within figures.
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\DeclareRobustCommand\circled[2][]{\ifthenelse{\isempty{#1}}{\tikz[baseline=(char.base)]{\node[shape=circle,fill=pairedOneLightBlue,inner sep=1pt] (char) {#2};}}{\autoref{#1}: \hyperref[#1]{\tikz[baseline=(char.base)]{\node[shape=circle,fill=pairedOneLightBlue,inner sep=1pt] (char) {#2};}}}}
\DeclareRobustCommand{\circled}[2][]{%
\ifthenelse{\isempty{#1}}%
{\circledbase{pairedOneLightBlue}{#2}}%
{\autoref{#1}: \hyperref[#1]{\circledbase{pairedOneLightBlue}{#2}}}%
}

% listings don't write "Listing" in autoref without this.
\providecommand*{\listingautorefname}{Listing}
Expand Down
35 changes: 34 additions & 1 deletion tex/setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Add minted and support costum lexers
% Add minted and support custom lexers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{minted}
\usepackage{etoolbox}
Expand Down Expand Up @@ -171,3 +171,36 @@
{
}
\makeatother

\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Base style and command for \circled to print a colored circle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Width is assured to be the same across all characters using the typewriter font which is monospaced
% Zeroing out the inner separator removes padding between content and node (inner sep).
% Zeroing out the outer separator removes space between the node border and its anchors (e.g., east).
% Minimum size was derived on experimentation and it may need adjustment when changing font style/size.
%
% There is no guarantee for the letter ascenders/descenders to baseline when set to char.base, hence adding \strut.
% which is an invisible vertical rule with the height and depth of the parentheses ( and ).
% It ensures that the line height in a line of text is at least as large as if it contained parentheses.
\tikzset{
circledstyle/.style={
shape=circle,
#1,
font=\tt\small,
inner sep=0pt,
outer sep=0pt,
minimum size=1.2em,
text=black
}
}

% define a base tikz node for circled commands accepting a fill colour and the node text as arguments
\DeclareRobustCommand{\circledbase}[3][]{%
\tikz[baseline=(char.base)]{\node[circledstyle, fill=#2] (char) {#3\strut};}%
}

0 comments on commit b300c93

Please sign in to comment.