Math & ScienceTwo times \dot in one term fails!

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Acement
Posts: 2
Joined: Wed Jul 25, 2012 11:56 am

Two times \dot in one term fails!

Post by Acement »

Hi

I have an equation that bothers me allot. When I compile this, the \dot{x} on the LHS is placed on top of the brackets. It seems to be a problem with the first \dot, \dot{\overline…}, removing this solves the problem. Can anyone see my error or a way to solve it?

Another strange thing is that something similar is on the RHS, where there are no problems!

Code: Select all

\documentclass[11pt,a4paper]{report}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}

\begin{equation}
\rho\dot{\overline{\left(\varepsilon+\tfrac{1}{2}\dot{x}^{2}\right)}}=\rho\dot{\varepsilon}+\rho\dot{\overline{\left(\tfrac{1}{2}\mathbf{\dot{x}}\cdot\mathbf{\dot{x}}\right)}}=\rho\dot{\varepsilon}+\rho\dot{\mathbf{x}}\cdot\ddot{\mathbf{x}}
\end{equation}

\end{document}
thanks in advance

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Two times \dot in one term fails!

Post by Stefan Kottwitz »

Hi,

welcome to the board!

Very nice, that you posted a small compilable example. So I could directly test it. Obviously there's a bug with nested \dot in amsmath. It works using the standard LaTeX \dot. So you can fix it by saving and restoring the original command:

Code: Select all

\let\stddot\dot
\usepackage{amsmath}
\let\dot\stddot
Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Two times \dot in one term fails!

Post by Stefan Kottwitz »

There's another solution, keeping the amsmath \dot, but defining an outer dot command which typesets the inner content first, within a box, before adding the outer dot. Such as:

Code: Select all

\newsavebox{\dotbox}
\newcommand{\outerdot}[1]{\sbox\dotbox{$#1$}\dot{\usebox\dotbox}}
Now you can replace the outer \dot by \outerdot.

The complete example:

Code: Select all

\documentclass[11pt,a4paper]{report}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\newsavebox{\dotbox}
\newcommand{\outerdot}[1]{\sbox\dotbox{$#1$}\dot{\usebox\dotbox}}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\begin{equation}
\rho\outerdot{\overline{\left(\varepsilon+\tfrac{1}{2}\dot{x}^{2}\right)}}
  =\rho\dot{\varepsilon}+\rho\outerdot{\overline{\left(\tfrac{1}{2}
    \mathbf{\dot{x}}\cdot\mathbf{\dot{x}}\right)}}
  =\rho\dot{\varepsilon}+\rho\dot{\mathbf{x}}\cdot\ddot{\mathbf{x}}
\end{equation}
\end{document}
dots.png
dots.png (2.85 KiB) Viewed 5024 times
Stefan
LaTeX.org admin
Acement
Posts: 2
Joined: Wed Jul 25, 2012 11:56 am

Re: Two times \dot in one term fails!

Post by Acement »

Thanks for the fast reply, the last suggestion was best for me. I'm using Lyx as main editor and it is easier to use the last reply here.
Post Reply