4

I would like to know if one token argument can be stretched by \big, \left and co.

Is there an easy way to test that a token is a maths delimiter, before starting to produce some output?

1
  • 2
    it's a character token with non zero delcode or a macro starting \delimiter (or \U... variants for luatex or xetex Apr 29, 2023 at 16:13

1 Answer 1

7

It's a character token with non zero delcode or a macro starting \delimiter (or \U... variants for luatex or xetex, which are left as an exercise for the reader)

enter image description here

\documentclass{article}

\makeatletter
\def\bigifdelim#1{%
\expandafter\def\expandafter\tmp\expandafter{\romannumeral-`x#1\relax}%
\edef\tmp{\expandafter\@car\tmp\@nil}%
\ifcat\relax\tmp
  \expandafter\ifx\expandafter\delimiter\tmp
    \Bigg#1_{\mathrm{big}}%
  \else 
    #1_{\mathrm{small}}%
  \fi
\else
  \ifnum\delcode\expandafter`\tmp>\z@
    \Bigg#1_{\mathrm{big}}%
  \else
    #1_{\mathrm{small}}%
  \fi
\fi
}
\makeatother
\begin{document}

$
%
\bigifdelim x
%
\bigifdelim (
%
\bigifdelim \lbrace
%
\bigifdelim \cos
%
$

\end{document}
3
  • Do you think this can be easily translated into expl3, or not?
    – projetmbc
    Apr 30, 2023 at 16:41
  • @projetmbc yes of course Apr 30, 2023 at 16:42
  • OK. I will do that and will come back here if I meet a wall...
    – projetmbc
    Apr 30, 2023 at 16:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .