Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix circled command #42

Merged
merged 8 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions paper.tex
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,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};}%
}

Loading