3

Assumed I have this MWE to align the units off right:

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}

\makeatletter
\providecommand\add@text{}
\newcommand\tagaddtext[1]{%
  \gdef\add@text{#1\gdef\add@text{}}}% 
\renewcommand\tagform@[1]{%
  \maketag@@@{\llap{\add@text\qquad}(\ignorespaces#1\unskip\@@italiccorr)}%
}
\makeatother

\begin{document}

Unfortunately the bracket does not fit to the height of the unit.
The units exponent is already positioned above the upper edge of the bracket. :-(

\begin{equation}
    A = B + C       \tagaddtext{[\si{\square\meter}]}
\end{equation}

How can I change this behavior?



\end{document}

Screenshot of the result:

Screenshot of the issue


Description of the eyesore:

As you can see the corresponding brackets do not automatically adapt to the height of the unit. The exponent is higher than the bracket.

How can I change that behavior, so that the brackets will automatically adjust to the height of the highest/lowest point of the unit?

  • 2
    You can use \tagaddtext{$\left[\si{\square\meter}\right]$}. But this is usually not recommended. The image you show is the correct behavior AFAIK. – Peter Grill Dec 6 '18 at 19:44
  • @PeterGrill: Thanks a lot! Could I implement the brackets into the \newcommand-configuration already? So that I only have to write \tagaddtext{\si{\square\meter}} into the document text and the brackets will show up automatically? – Dave Dec 6 '18 at 19:47
  • @PeterGrill: Excuse me, one more question: Why is your approach usually not recommended? Is it faulty typography to increase the brackets size matching to the exponents? – Dave Dec 6 '18 at 21:57
  • @PeterGrill: Ah, I understand! Thank you very much for your help! I will stop using \left[ ... \right] now at all. I never tought about those spacing problems... – Dave Dec 7 '18 at 8:27
2

I propose for what it's worth a work-around with flalign and an \addunit command:

\documentclass{article}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}
\usepackage{mathtools}
\usepackage{siunitx}

\newcommand{\addunit}[1]{\mathllap{\left[\si{#1}\right]\quad}}

\begin{document}

\begin{flalign}
 & & A & = B + C & & \addunit{\square\meter}
\end{flalign}

\end{document} 

enter image description here

| improve this answer | |
  • Thanks a lot! So I should stop using \begin{equation}blabla\end{equation}? Or better use \begin{flalign} inside of \begin{equation}? – Dave Dec 6 '18 at 21:46
  • If you want to use \addunit , yes, use flalign in the place of equationflalign can't be used inside another math environment, and flaligned does not exist. – Bernard Dec 6 '18 at 21:51

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.