2

As you can see, underset on right hand becomes overlaped. How can I avoid this? This is my MWE

\documentclass[14pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\newcommand{\lunderset}[2]{\underset{\mathrlap{#1}}{\mathrlap{#2}}\phantom{#2}}

\begin{document}
    \begin{equation}
         \lunderset{\text{legame}}{\Delta G} = 
         \lunderset{\text{van der Waals}}{\Delta G} + 
         \lunderset{\text{legami H}}{\Delta G} + 
         T\Delta S
    \end{equation}
\end{document}

enter image description here

3
  • Off-topic: The option 14pt is not recognized by the article document class and is simply ignored.
    – Mico
    Commented Jul 3 at 19:17
  • 1
    You could use plain old \underset instead of using \mathrlap to cause the overlaps. Commented Jul 3 at 20:15
  • 1
    the problem is not underset it is \mathrlap the only purpose of that command is to make the text overLAP on the Right, which is what you show. Commented Jul 3 at 20:29

4 Answers 4

3

I suggest you shift the text of the middle \lunderset directive down, by inserting a \substack directive.

enter image description here

I can't help but remark that I don't find this setup easily readable.

\documentclass[12pt]{article}
\usepackage{mathtools}
\newcommand{\lunderset}[2]{\underset{\mathclap{#1}}{#2}}

\begin{document}
\[
  \lunderset{\text{legame}}{\Delta G} = 
  \lunderset{\substack{\uparrow \\ \text{van der Waals}}}{\Delta G} + 
  \lunderset{\text{legami H}}{\Delta G} + 
  T\Delta S
\]
\end{document}
1

The problem is not \underset, it is \mathrlap the only purpose of that command is to make the text overLAP on the Right, which is what you show.

If you must do this, I'd give yourself a bit more room by padding the base symbol, and then set the underset text as small as possible, abbreviating if necessary.

enter image description here

\documentclass{article}% there is no 14pt option
% not needed as you have mathtools \usepackage{amsmath}
\usepackage{mathtools}
\newcommand{\lunderset}[2]{%
  \underset{\clap{\tiny#1}}{\,#2\,}}

\begin{document}
    \begin{equation}
         \lunderset{legame}{\Delta G} = 
         \lunderset{v.d.Waals}{\Delta G} + 
         \lunderset{legami H}{\Delta G} + 
         T\Delta S
    \end{equation}
\end{document}
1

Just for fun. It still can do nothing about text which is too wide for the box (unless you add hyphenation).

\documentclass[14pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{mathstyle}

\makeatletter
\newcommand{\mathsavebox}[2]{%
  \global\setbox#1=\hbox{$\m@th\currentmathstyle#2$}%
}
\makeatother

\newcommand{\lunderset}[2]{\mathsavebox1{#2}\underset{\parbox[t]{\wd0}{\centering\tiny #1}}{#2}}

\begin{document}
    \begin{equation}
         \lunderset{legame}{\Delta G} = 
         \lunderset{van der Waals}{\Delta G} + 
         \lunderset{legami H}{\Delta G} + 
         T\Delta S
    \end{equation}
\end{document}

demo

2
  • don't make global assignments to even numbered scratch boxes, use 1 not 0 but why global? Commented Jul 3 at 20:45
  • 1
    I keep forgetting whether to use odd or even numbers. Commented Jul 3 at 20:49
1

I did it

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{calc}
\newcommand{\lunderset}[2]
{\underset
{ \parbox{\widthof{\scriptsize{#1}}}{\scriptsize{#1}}}
{ \parbox{\widthof{\scriptsize{#1}}}{$#2$}}}

\begin{document}
\begin{equation}
\lunderset{\text{legame}}{\Delta G} = 
\lunderset{\text{van der Waals}}{\Delta G} + 
\lunderset{\text{legami H}}{\Delta G} + 
T\Delta S
\end{equation}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .