3

I have a non-standard setup for my symbols. Instead of defining them explicitly in every equation, e.g.:

\begin{equation}
a_i={\bf b}^{(est)}_i \cdot {\bf c}^{(obs)}_i
\end{equation}

I define acronyms (with the acronym package):

\acro{a}[$a$]{scalar quantity a}
\acro{b}[${\bf b}$]{vector quantity b}
\acro{c}[${\bf c}$]{vector quantity c}
\acro{epoch.i}[$_i$]{epoch $i$}
\acro{dot}[$\cdot$]{dot product}
\acro{est}[$^{(est}}$]{estimated}
\acro{obs}[$^{(obs}}$]{observed}

... and use the short form in the equations:

\begin{equation}
\acs{a}\acs{epoch.i}=\acs{b}\acs{est}\acs{epoch.i}\acs{dot}\acs{c}\acs{obs}\acs{epoch.i}
\end{equation}

The motivation to do things in this way is do that I can relate a symbol to its meaning textually, such as:

The \acl{obs} \acl{b} is represented by \acs{b}\acs{obs}.

... and I get a consistent list of symbols for free.

The problem is when there are superscript mixed with subscripts, e.g.:

{\bf b}^{(est)}_i;

... what I effectively get is:

${\bf b}$$^{(est)}$$_i$

... which means that there is a concatenation of math environments instead of a continuous one, resulting that the subscript appears after the superscript and not under it, as in the usual way.

Any suggestions to fix this without destroying my nice acronym setup?

  • Welcome to TeX.SX!. When asking questions it is better to provide a full minimal working example (MWE) both in order to demonstrate what you are trying to do and to help others help you. The MWE should like like \documentclass...\begin{document}...\end{document}, it should compile and contain close to the minimal amount of code needed to explain/demonstrate what you are asking. This saves a lot of time for everyon – Andrew Oct 27 '14 at 12:22
  • 1
    This must surely generate errors in any display math environment not just in superscripts, also it will generate poorer spacing than would otherwise be the case your _i for example, will always superscript a null atom and so will not take account of the size of the thing being subscripted or of any font specified kerning: compare $P_i$ with $P{}_i$ – David Carlisle Oct 27 '14 at 12:47
  • @Andrew, thanks for the heads up. I forgot about the MWE. My bad. I focused on explaining the issue but that's no substitute, I understand. – Joao Encarnacao Oct 27 '14 at 13:31
0

I don't really know how much can go wrong with this; for instance it doesn't work with hyperref, but is a starting point.

\documentclass{article}
\usepackage[printonlyused,withpage]{acronym}

\protected\def\EM#1{\relax\ifmmode#1\else$#1$\fi}
\makeatletter
\newcommand\acsm[1]{%
  \@ifundefined{fn@#1}
    {\underline{#1}}
    {\expandafter\expandafter\expandafter\@firstoftwo\csname fn@#1\endcsname}%
}
\makeatother

\begin{document}

\begin{acronym}
  \acro{a}[\EM{a}]{scalar quantity a}
  \acro{b}[\EM{\mathbf{b}}]{vector quantity b}
  \acro{c}[\EM{\mathbf{c}}]{vector quantity c}
  \acro{epoch.i}[\EM{_i}]{epoch $i$}
  \acro{dot}[\EM{\cdot}]{dot product}
  \acro{est}[\EM{^{(est)}}]{estimated}
  \acro{obs}[\EM{^{(obs)}}]{observed}
  \acro{sum}[\EM{\sum}]{sum}
\end{acronym}

\begin{equation}
\acsm{a}\acsm{epoch.i}=\acsm{b}\acsm{est}\acsm{epoch.i}\acsm{dot}\acsm{c}\acsm{obs}\acsm{epoch.i}
\end{equation}

\[\acsm{b}\acsm{est}\acsm{epoch.i}\acsm{sum}_{1\le k\le n}a_k\]

\end{document}

enter image description here

4

Seems like a strange way to write TeX to me:) Nonetheless, I think that you can do what you want if you just use \ensuremath instead of explicitly entering math-mode with $...$ inside your acronyms:

\documentclass{article}
\usepackage[printonlyused,withpage]{acronym}

\begin{document}

\begin{acronym}
  \acro{a}[\ensuremath{a}]{scalar quantity a}
  \acro{b}[\ensuremath{{\mathbf b}}]{vector quantity b}
  \acro{c}[\ensuremath{{\mathbf c}}]{vector quantity c}
  \acro{epoch.i}[\ensuremath{{}_i}]{epoch $i$}
  \acro{dot}[\ensuremath{\cdot}]{dot product}
  \acro{est}[\ensuremath{{}^{(est)}}]{estimated}
  \acro{obs}[\ensuremath{{}^{(obs)}}]{observed}
\end{acronym}

\begin{equation}
\acs{a}\acs{epoch.i}=\acs{b}\acs{est}\acs{epoch.i}\acs{dot}\acs{c}\acs{obs}\acs{epoch.i}
\end{equation}

$\acs{b}\acs{est}\acs{epoch.i}$


\end{document}
  • 1
    I know you copied from the OP, but \bf b should be \mathbf{b} and (est) should be \mathrm(est) and same for obs – David Carlisle Oct 27 '14 at 12:41
  • @DavidCarlisle, you are correct. I posted the question quickly and overlooked that. Thank you for the correction. – Joao Encarnacao Oct 27 '14 at 13:28
  • @Andrew, thank you. Your example is very useful because of things like \ensuremath{{}^{(est}}. – Joao Encarnacao Oct 27 '14 at 13:30
  • I'm afraid I was too quick to identify this as the correct answer. In fact, the sub/superscript appear one after the other, not flushed to the left next to the main symbol. Compare: $\ensuremath{{\mathbf b}}\ensuremath{{}^{(est)}}\ensuremath{{}_i}$ (not good) with $\ensuremath{{\mathbf b}}\ensuremath{^{(est)}}\ensuremath{_i}$. Unfortunately, even defining the acronyms without the {} particle does not help. For this reason, I removed the green tick mark from this answer. – Joao Encarnacao Oct 30 '14 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.