Why does LaTeX issue \scriptsize warnings in math mode?

David Carlisle d.p.carlisle at gmail.com
Thu May 7 22:52:55 CEST 2020

On Thu, 7 May 2020 at 19:57, Doug McKenna <doug at mathemaesthetics.com> wrote:

> Thanks for the helpful responses.
>
> The combination of \scriptstyle, \scriptscriptstyle, and \mathtt{} seems
> to work equivalently, as long as the characters are all letters or digits.
> But what can be placed between the delimiters of \verb| ... | and what can
> be placed inside a \mathtt{ ... } are not the same, and I'm pretty sure the
> characters inside \mathtt{ ... } are more restricted.
>
> My problem is that I don't have control over the characters I want to be
> verbatimed; they are coming from somewhere else and being inserted into the
> LaTeX document.  And I definitely want to be able to use a piece of
> verbatim text as a superscript or a subscript, and yes I know that's not
> the "right" thing for a math formula, except that in what I'm doing, it
> really is.
>
> So the following all seem to do what I want, and there are no LaTeX
> warnings or errors:
>
> \documentclass{letter}
> \begin{document}
>
> \verb|box7|
>

thi sone is OK although of course verb isn't being used here, it's just
\texttt{box7}

>
> $\hbox{\verb|box7|}$
>

That works but isn't supported latex (using \hbox primitive mid document,
again it's just $\mathtt{box7}$ (or $\texttt{box7}$)

>
> {\setbox7=\hbox{\verb|box7|}$\box7$}
>

again the latex syntax here would by \sbox7{\texttt{box7}\usebox{7}}  (the
math mode isn't doing anything aroundthe box register use)

>
> {\setbox7=\hbox{\scriptsize \verb|box7|}$2^{\box7}$}
>

this might do the right thing if \scriptsize is the same size and font as
math mode  \scriptstyle which is not guaranteed (especially teh fonts are
often different.
also it is using primitive tex constricts not latex

>
> {\setbox7=\hbox{\tiny \verb|box7|}$2^{2^{\box7}}$}
>

as for \scriptstyle but there is an even bigger chance that \tiny and
\scriptscriptstyle are different sizes (as there was never any intention to
make them the same, although they may be in some classes)

> \end{document}
>
> The second example works but is questionable according to previous
> responses.  Are there downsides for the other examples that build the
> verbatim text in a box first, outside of math mode?
>
> Doug McKenna
> Mathemaesthetics, Inc.
>
>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20200507/7ab03f00/attachment.html>


More information about the texhax mailing list.