Skip to content

Commit 093c4e6

Browse files
committed
feat(math): automatic scaling of argument placeholder
Signed-off-by: Jonas Dujava <[email protected]>
1 parent af0266e commit 093c4e6

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

preamble/math/macros.tex

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,18 @@
229229
\NewDocumentCommand{\ind}{}{\mathcolor{lightgray}{\bullet}}
230230

231231
%% Argument placeholder
232-
\NewDocumentCommand{\argument}{s O{} O{1}}{%
233-
\def\squaresize{1.0}% % default size
234-
\IfBooleanT{#1}{\def\squaresize{0.7}}% % if starred, set size corresponding to scriptstyle
235-
\IfBlankF{#2}{\def\squaresize{#2}}% % if optional argument is passed, set size to custom value
236-
% TODO: utilize \mathpalette
237-
\scalebox{\squaresize}{%
238-
\begin{tikzpicture}[baseline=-#3*0.6ex]
239-
\node(char)[draw, shape=rectangle, dash=on 1.2pt off 1.05pt phase 0.5pt, dash expand off,
240-
inner ysep=2pt, inner xsep=2pt, minimum size=0.6em, rounded corners=2pt] {};
241-
%% alternative:
242-
% \node(char)[draw, shape=rectangle, dash=on 1.1pt off 0.8pt phase 0.5pt, dash expand off,
243-
% inner ysep=2pt, inner xsep=2pt, minimum size=0.6em, rounded corners=2pt] {};
244-
\end{tikzpicture}%
232+
\newsavebox{\argumentbox}
233+
\sbox{\argumentbox}{%
234+
\begin{tikzpicture}[baseline=-0.6ex]
235+
\node(char)[draw, shape=rectangle, dash=on 1.2pt off 1.05pt phase 0.5pt, dash expand off,
236+
inner ysep=2pt, inner xsep=2pt, minimum size=0.6em, rounded corners=2pt] {};
237+
\end{tikzpicture}%
238+
}
239+
\NewDocumentCommand{\argument}{o}{%
240+
\IfValueTF{#1}{% use #1 as a scaling factor, resizebox relative to the text size
241+
\scalebox{#1}{\resizebox{!}{0.58em}{\usebox{\argumentbox}}}
242+
}{% choose scaling factor based on display/text/script/scriptscript math style
243+
\mathchoice{\argument[1.0]}{\argument[1.0]}{\argument[0.7]}{\argument[0.6]}
245244
}%
246245
}
247246

0 commit comments

Comments
 (0)