Discussion:
amsmath; custom stackrel: tag in margin
Add Reply
Ronnie Marksch
2020-07-11 09:50:50 UTC
Reply
Permalink
Hi,

I once found the Stackrel macro on the internet but now, it seems to
mess with the tag placement.
When using \Stackrel, the tag is placed in the margin.

Do you have an idea how make both things work?

Best,
Ronnie

\documentclass{article}

\usepackage{amsmath,xifthen}

\usepackage[pass,showframe]{geometry}%

\makeatletter
\newlength{\***@A}
\newlength{\***@B}

\let\***@start@align\***@align
\def\***@align{%
\global\***@A=\z@
\***@start@align
}
\newcommand\Stackrel[2]{%
\settowidth\***@B{$\stackrel{#1}{}$}%
\ifmeasuring@
\ifdim\***@B>\***@A
\global\***@A=\***@B
\fi
\else
\advance\***@B-\***@A
\***@B-.5\***@B
\ifthenelse{\isempty{#2}}{#1}{\stackrel{%
\kern\***@B
#1%
\kern\***@B
}{#2}}%
\fi
}
\makeatother

\begin{document}

\begin{align*}
&b\\
\Stackrel{foo}{\Longleftrightarrow}&b\tag{A}\\
\end{align*}

\begin{align*}
&b\\
\stackrel{foo}{\Longleftrightarrow}&b\tag{A}\\
\end{align*}

\end{document}
Holger Schieferdecker
2020-07-14 06:50:51 UTC
Reply
Permalink
Post by Ronnie Marksch
Hi,
I once found the Stackrel macro on the internet but now, it seems to
mess with the tag placement.
When using \Stackrel, the tag is placed in the margin.
In my test \Stackrel also seems to mess with the placement of the
equation itself. It is shifted to the right as well (but less than the tag).
Post by Ronnie Marksch
Do you have an idea how make both things work?
What's wrong with the "normal" \stackrel?

Holger
Ronnie Marksch
2020-07-15 10:51:03 UTC
Reply
Permalink
Hi,

the purpose of Stackrel is that if there are multiple lines that the
\Longleftrightarrow symbols are aligned.
For this purpose, each Stackrel is measured and suitable space is added
left/right of each Stackrel.

However, somehow, this procedure for aligning interferes with the tag
placement.
This came as a surprise to me because, in the past, I did not use tags
and Stackrel in combination.

Ronnie
Post by Holger Schieferdecker
Post by Ronnie Marksch
Hi,
I once found the Stackrel macro on the internet but now, it seems to
mess with the tag placement.
When using \Stackrel, the tag is placed in the margin.
In my test \Stackrel also seems to mess with the placement of the
equation itself. It is shifted to the right as well (but less than the tag).
Post by Ronnie Marksch
Do you have an idea how make both things work?
What's wrong with the "normal" \stackrel?
Holger
Ronnie Marksch
2020-07-16 06:09:53 UTC
Reply
Permalink
Apparently, the stackrel also had to be printed in the measuring phase.

\documentclass{article}

\usepackage{amsmath,xifthen}

\usepackage[pass,showframe]{geometry}%

\makeatletter
\newlength{\***@A}
\newlength{\***@B}

\let\***@start@align\***@align
\def\***@align{%
\global\***@A=\z@
\***@start@align
}
\newcommand\Stackrel[2]{%
\settowidth\***@B{$\stackrel{#1}{#2}$}%
\ifmeasuring@
\ifdim\***@B>\***@A
\global\***@A=\***@B
\fi
\stackrel{#1}{#2}%
\else
\advance\***@B-\***@A
\***@B-.5\***@B
\stackrel{\kern\***@B#1\kern\***@B}{#2}
\fi
}
\makeatother

\begin{document}

\begin{align*}
&b\\
\Stackrel{foofoofoo}{\Longleftrightarrow}&b\tag{A}\\
\Stackrel{foo}{\Longleftrightarrow}&b\tag{A}\\
\end{align*}

\begin{align*}
&b\\
\stackrel{foo}{\Longleftrightarrow}&b\tag{A}\\
\stackrel{foo}{}&b\tag{A}\\
\end{align*}

\end{document}
Post by Ronnie Marksch
Hi,
the purpose of Stackrel is that if there are multiple lines that the
\Longleftrightarrow symbols are aligned.
For this purpose, each Stackrel is measured and suitable space is added
left/right of each Stackrel.
However, somehow, this procedure for aligning interferes with the tag
placement.
This came as a surprise to me because, in the past, I did not use tags
and Stackrel in combination.
Ronnie
Post by Holger Schieferdecker
Post by Ronnie Marksch
Hi,
I once found the Stackrel macro on the internet but now, it seems to
mess with the tag placement.
When using \Stackrel, the tag is placed in the margin.
In my test \Stackrel also seems to mess with the placement of the
equation itself. It is shifted to the right as well (but less than the tag).
Post by Ronnie Marksch
Do you have an idea how make both things work?
What's wrong with the "normal" \stackrel?
Holger
Loading...