Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The problem is the odd placement of g in the second line in the align environment. Strangely, the \dot{}-character is only misplaced if it is followed by another character. I need the mathabx package for some symbols and would therefore prefer an alternative to this question. Without mathabx everything works as expected.

\documentclass[10pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage{mathtools}
\usepackage{mathabx} 
\begin{document}
\begin{align*}
\widetilde{g\dot{g}}\\
\widetilde{\dot{g}g}
\end{align*}
\end{document}
share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

The problem is the same as exposed in Why do arguments to nested \tilde or \breve commands reappear when amsmath is used? Here it appears in a less spectacular way, the effect of mathabx is just to produce it also with widetilde. The solution is always the same:

\documentclass[10pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage{mathtools}
\usepackage{mathabx}

\newsavebox{\accentbox}
\newcommand{\compositeaccents}[2]{%
  \sbox\accentbox{$#2$}#1{\usebox\accentbox}}

\begin{document}
\begin{align*}
\compositeaccents{\widetilde}{g\dot{g}}\\
\compositeaccents{\widetilde}{\dot{g}g}
\end{align*}

\end{document}

Of course, you can use whatever name you want instead of \compositeaccents.

enter image description here

share|improve this answer
    
Thank you! Especially your answer in the linked question above is very instructive. –  gofvonx Jan 13 at 21:06
add comment

One fix is to put the expression in a box first (incorporating it into a redefined \widetilde):

\documentclass[10pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage{mathtools}
\usepackage{mathabx} 
\newsavebox\tempbox
\let\svwidetilde\widetilde
\renewcommand\widetilde[1]{\sbox\tempbox{$#1$}\svwidetilde{\usebox{\tempbox}}}
\begin{document}
\begin{align*}
\widetilde{g\dot{g}}\\
\widetilde{\dot{g}g}
\end{align*}
\end{document}

enter image description here

Alternately, one can, as a workaround, use scalerel package to stretch the tilde, and stackengine package to set it atop the expression.

\documentclass[10pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage{mathtools}
\usepackage{mathabx} 
\usepackage{stackengine}
\stackMath
\usepackage{scalerel}
\begin{document}
\begin{align*}
\widetilde{g\dot{g}}\\
\stackon[0pt]{\dot{g}g}{\hstretch{1.4}{\sim}}\\
%\widetilde{\dot{g}g}
\end{align*}
\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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