I was writing part of a slightly mathematical paper in LaTeX and I came across the following problem. I worked out an alternative (and good) solution to my problem, but I'm very curious if anyone knows how to do this (MWE at the end of the post).
I want to be able to add superscript and subscript to a custom command that I made for the paper. Consider the following command:
\NewDocumentCommand \conceptsymbol {} {L}
\NewDocumentCommand \conceptvalue { m O{\conceptsymbol} } { #2(#1) }
I made this because the paper is still in early stages and we might change the symbols. Consider now the following four possibilities ($ omitted for brevity's sake)
\conceptsymbol, \conceptsymbol', \conceptsymbol_1 and \conceptsymbol_1'.
These would be rendered as L, L', L_1 and L_1'. I have no problems with this, however, I would like to refer to some property of each concept using the conceptvalue. I can easily change the symbol used in the conceptvalue as optional parameter. I can use the default parameter
\conceptvalue{i} % L(i)
or I can set a different value
\conceptvalue{i}[\conceptsymbol'] % L'(i)
\conceptvalue{i}[\conceptsymbol_1] % L_1(i)
\conceptvalue{i}[\conceptsymbol_1'] % L_1'(i)
I would like to do the same but in a shorter way. For example, I could write
\conceptvalue{i}' % L(i)'
\conceptvalue{i}_1 % L(i)_1
\conceptvalue{i}_1' % L(i)_1'
but this does not produce the correct render of the symbols. Does somebody know how to shorten this? Thanks to you all!
Full MWE:
\documentclass[12pt]{article}
\pdfoutput=1
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xparse}
\usepackage{booktabs}
\usepackage{multicol}
\NewDocumentCommand \conceptsymbol {} {L}
\NewDocumentCommand \conceptvalue { m O{\conceptsymbol} }
{ #2(#1) }
\begin{document}
\allowdisplaybreaks
\title{The hardest part of any paper is dealing with \LaTeX}
\author{Me, myself, and some nice {\tt tex.stackexchange} users}
\maketitle
\section{Please, help}
My commands are:
\begin{verbatim}
\NewDocumentCommand \conceptsymbol {} {L}
\NewDocumentCommand \conceptvalue { m O{\conceptsymbol} }
{ #2(#1) }
\end{verbatim}
Assume that $\conceptsymbol$ refers to a sequence of $n$ elements and that $\conceptvalue{i}$ denotes the $i$th element in the sequence. Suppose now that I have several sequences $\conceptsymbol$, $\conceptsymbol'$, $\conceptsymbol_1$ and $\conceptsymbol_1'$.
{\small
\begin{table}[h]
\centering
\begin{tabular}{cl}
\toprule
\multicolumn{2}{c}{What I have} \\
\midrule
$\conceptvalue{i}$ & \verb|\conceptvalue{i}| \\
$\conceptvalue{i}'$ & \verb|\conceptvalue{i}'| \\
$\conceptvalue{i}_1$ & \verb|\conceptvalue{i}_1| \\
$\conceptvalue{i}_1'$ & \verb|\conceptvalue{i}_1'| \\
\midrule
$\conceptvalue{i}$ & \verb|\conceptvalue{i}| \\
$\conceptvalue{i}[\conceptsymbol']$ & \verb|\conceptvalue{i}[\conceptsymbol']| \\
$\conceptvalue{i}[\conceptsymbol_1]$ & \verb|\conceptvalue{i}[\conceptsymbol_1]| \\
$\conceptvalue{i}[\conceptsymbol_1']$ & \verb|\conceptvalue{i}[\conceptsymbol_1']| \\
\bottomrule
\end{tabular}
\quad
\begin{tabular}{cl}
\toprule
\multicolumn{2}{c}{Shorter way?} \\
\midrule
$\conceptsymbol(i)$ & ? \\
$\conceptsymbol'(i)$ & ? \\
$\conceptsymbol_1(i)$ & ? \\
$\conceptsymbol_1'(i)$ & ? \\
\bottomrule
\end{tabular}
\end{table}
}
\end{document}

\conceptvalue'{i}(the'goes into a parameter), then I point out that it cannot do\conceptvalue_{12}{i}because it captures up to the first brace → only capture the_– user202729 Mar 30 '22 at 06:06