3

It is well known that in LaTeX $ABCD$ is different from $\mathit{ABCD}$ as the former represents the multiplication of four variables while the latter represents some single object such as a rectangle.

In solid geometry, suppose there is a cuboid ABCD-A1B1C1D1. Which one of the following is preferred/recommended? From the output it seems that \mathit is unnecessary for A1B1C1D1.

\documentclass{article}
\begin{document}

\begin{itemize}
  \item $\mathit{ABCD}$-$\mathit{A_1B_1C_1D_1}$
  \item $\mathit{ABCD}$-$\mathit{A_{\mathnormal{1}}B_{\mathnormal{1}}C_{\mathnormal{1}}D_{\mathnormal{1}}}$
  \item $\mathit{ABCD}$-$A_1B_1C_1D_1$
\end{itemize}

\end{document}

enter image description here

8
  • \mathit{A}_{1} is right; \mathit{A_{\mathnormal{1}}} is definitely wrong. Commented yesterday
  • @egreg Then the input is something like $\mathit{ABCD}$-$\mathit{A}_1\mathit{B}_1\mathit{C}_1\mathit{D}_1$. Well, quote tedious :-( Commented yesterday
  • Any fast way to simplify the input procedure?@egreg Commented yesterday
  • make a macro? \newcommand\cuboid[5][1]{\mathit{#2}_{#1}\mathit{#3}_{#1}\mathit{#4}_{#1}\mathit{#5}_{#1}} so \cuboid{A}{B}{C}{D} \cuboid[3]{E}{F}{G}{H} or something? Commented yesterday
  • 1
    @Stephen What kind of output are you planning to get? Is it just on the same vein or are there different forms? Commented yesterday

2 Answers 2

2

You can process the input:

\documentclass{article}
\usepackage{amsmath}

\ExplSyntaxOn

\NewDocumentCommand{\cuboid}{m}
 {
  \stephen_cuboid:n {#1}
 }

\cs_new_protected:Nn \__stephen_cuboid_sep: { \mbox{\normalfont-} }

\cs_new_protected:Nn \stephen_cuboid:n
 {
  \tl_map_function:nN {#1} \__stephen_cuboid_process:n
 }
\cs_new_protected:Nn \__stephen_cuboid_process:n
 {
  \str_case:nnF {#1}
   {
    {0}{\sb{0}}
    {1}{\sb{1}}
    {2}{\sb{2}}
    {3}{\sb{3}}
    {4}{\sb{4}}
    {5}{\sb{5}}
    {6}{\sb{6}}
    {7}{\sb{7}}
    {8}{\sb{8}}
    {9}{\sb{9}}
    {-}{\__stephen_cuboid_sep:}
   }
   { \mathit{#1} }
 }

\ExplSyntaxOff

\begin{document}

$\cuboid{ABCD-A1B1C1D1} \ne \cuboid{ABCD-EFGH}$

\end{document}

output

You can freely use spaces in the input, so

\cuboid{A B C D - A1 B1 C1 D1}

would print the same.

If I replace - with -- in the definition of \__stephen_cuboid_sep:, the output becomes

output 2

You may want to try also

\cs_new_protected:Nn \__stephen_cuboid_sep: {{-}}
4

ABCD although written that way isn't really a single identifier it is the concatenation of the identifiers of the corners so $ABCD$ seems the natural markup simimilarly $A_1B_1C_1D_1$ or better (but equivalent) $A_{1}B_{1}C_{1}D_{1}$ for the subscripted forms.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.