-
Notifications
You must be signed in to change notification settings - Fork 23
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
3-line mathmode setting for upright indices wont work anymore #57
Comments
This is related to the usage of package I would suggest a slightly different approach for creating upright subscripts, inspired by https://tex.stackexchange.com/a/496613 \documentclass{tudscrartcl}
\makeatletter
\newcommand*\mathsub@upright[1]{\sb{\mathrm{#1}}}
\newcommand*\mathsub@italic[1]{\sb{\mathit{#1}}}
\newcommand*\mathsub@default{}
\newcommand*\mathsub@variant{}
\begingroup%
\catcode`\_=13%
\gdef_{%
\kernel@ifnextchar(%)
{\mathsub@variant}%
{\mathsub@default}%
}%
\gdef_{\@ifnextchar|\mathsub@variant\mathsub@default}%
\endgroup%
\AtBeginDocument{%
% default setting if \[upright|italic]subscripts wasn't invoked so far
\ifx\mathsub@variant\@empty\italicsubscripts\fi%
\mathcode`_="8000%
\catcode`\_=12%
}
\newcommand*\uprightsubscripts{
\let\mathsub@default\mathsub@upright%
\def\mathsub@variant(##1){\mathsub@italic{##1}}%
\def\mathsub@variant|##1|{\mathsub@italic{##1}}%
}
\newcommand*\italicsubscripts{%
\let\mathsub@default\mathsub@italic%
\def\mathsub@variant(##1){\mathsub@upright{##1}}%
\def\mathsub@variant|##1|{\mathsub@upright{##1}}%
}
\makeatother
\begin{document}
$a_(b)$
$a_(bv)$
$a_|b|$
$a_|bv|$
$a_b$
$x_{default}$
$x_(variant)$
$x_|variant|$
\uprightsubscripts
$a_(b)$
$a_(bv)$
$a_|b|$
$a_|bv|$
$a_b$
$x_{default}$
$x_(variant)$
$x_|variant|$
\italicsubscripts
$a_(b)$
$a_(bv)$
$a_|b|$
$a_|bv|$
$a_b$
$x_{default}$
$x_(variant)$
$x_|variant|$
\end{document} EDIT: Regarding #57 (comment), changed from |
Am 15.03.21 um 12:41 schrieb Falk Hanisch:
In order to get the contrary output, you only have to use `$x_|subscript|$` instead of the normal syntax `$x_{subscript}$`.
Why don't you suggest to use `[` and `]`? It is common LaTeX for
optional arguments and has asymmetric borders.
|
Well, the argument is not optional but a variant for the mandatory one. Nevertheless, asymmetric borders is a point, changed from |
Ah alright. Im not going to pretend, I fully understand whats been done neither in my original snippets or your solution, but many thanks. |
Leave open as potential feature for a future release |
That would be great. Especially since upright indices are expected most of the time throughout TUD. This does not seem to work when using predefined symbols with glossaries when using said syumbols with |
please open a new issue and provide a mwe |
According to https://tex.stackexchange.com/q/62705 and https://tex.stackexchange.com/q/245880 a slightly different and (hopefully) more robust solution considering text mode as well \documentclass{tudscrartcl}
\usepackage[T1]{fontenc}
\makeatletter
\newcommand*\mathsub@upright[1]{\sb{\mathrm{#1}}}
\newcommand*\mathsub@italic[1]{\sb{\mathit{#1}}}
\newcommand*\mathsub@default{}
\newcommand*\mathsub@variant{}
\newcommand*\uprightsubscripts{
\let\mathsub@default\mathsub@upright%
\def\mathsub@variant(##1){\mathsub@italic{##1}}%
}
\newcommand*\italicsubscripts{%
\let\mathsub@default\mathsub@italic%
\def\mathsub@variant(##1){\mathsub@upright{##1}}%
}
\newcommand*\mathsub@choice{%
\kernel@ifnextchar(%)
{\mathsub@variant}%
{\mathsub@default}%
}
\catcode`\_=\active%
\gdef_{\relax\ifmmode\expandafter\mathsub@choice\else\textunderscore\fi}%
\AtBeginDocument{%
% ensure right catcodes
\catcode`\_=\active%
\mathcode`_="8000%
% default setting if \[upright|italic]subscripts wasn't invoked so far
\ifx\mathsub@variant\@empty\italicsubscripts\fi%
}
\makeatother
\usepackage{hyperref}
\begin{document}
\begin{figure}
\caption{$x_y$}
\label{z}
\end{figure}
bar_{foo}
bar_(foo)
$bar_{foo}$
$bar_(foo)$
\bigskip
$a_(b)$
$a_(bv)$
$a_b$
$x_{default}$
$x_(variant)$
\uprightsubscripts
$a_(b)$
$a_(bv)$
$a_b$
$x_{default}$
$x_(variant)$
\italicsubscripts
$a_(b)$
$a_(bv)$
$a_b$
$x_{default}$
$x_(variant)$
\end{document} |
Final solution can be found here: #58 (comment) |
I noticed, that this probably known "setting" for upright indices in mathmode without a need for single
\mathrm{}
every time, no longer works with tudscr. I havnt used tudscr for a while, but it worked at least 1-2 yrs ago.Furthermore is it working when using scr itself or even article, as following MWE might prove.
In case it is not as common as I thought, I cant remember where I first found this "setting", but it is described here as well.
The text was updated successfully, but these errors were encountered: