4

How to align the words "direção x", "direção y" with the word "continuidade"?

enter image description here

\begin{equation}\label{eq:mx}
\frac{\partial u}{\partial t} = - \left(u\frac{\partial u}{\partial x} 
+ v\frac{\partial u}{\partial y}\right) - \frac{\partial P}{\partial 
x} + 
\frac{1}{Re}\left(\frac{\partial^2u}{\partial x^2} + 
\frac{\partial^2u}{\partial y^2}\right)
\hspace{8ex}
\mbox{direção x}
\end{equation}
\begin{equation}\label{eq:my}
\frac{\partial v}{\partial t} = - \left(u\frac{\partial v}{\partial x} 
+ v\frac{\partial v}{\partial y}\right) - \frac{\partial P}{\partial 
y} + 
\frac{1}{Re}\left(\frac{\partial^2v}{\partial x^2} + 
\frac{\partial^2v}{\partial y^2}\right)
\hspace{8ex}
\mbox{direção y}
\end{equation}
\begin{equation}\label{eq:cm}
\frac{\partial u}{\partial x} + \frac{\partial v}{\partial y} = 0
\hspace{8ex}\mbox{continuidade}
\end{equation}

Edit:I want align just the words: "direção x", "direção y" and "continuidade". The equations can stay in the same position as in the figure.

Mateus
  • 451
  • Are you aware of the align environment? Perhaps you might want to make your question more specific, i.e. indicate whether you wish the alignment of the equations as shown in your post, or want to align the = signs. –  Oct 27 '17 at 17:21
  • I want align just the words: "direção x", "direção y", "continuidade". The equations can stay in the same position. – Mateus Oct 27 '17 at 17:23

4 Answers4

2

Since align uses r/l alignments, there was still a little manual fiddling to quasi-center the bottom equation.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\label{eq:mx}
\frac{\partial u}{\partial t} = - \left(u\frac{\partial u}{\partial x} 
+ v\frac{\partial u}{\partial y}\right) - \frac{\partial P}{\partial 
x} + 
\frac{1}{Re}\left(\frac{\partial^2u}{\partial x^2} + 
\frac{\partial^2u}{\partial y^2}\right)
&\hspace{8ex}
\mbox{direção x}
\\\label{eq:my}
\frac{\partial v}{\partial t} = - \left(u\frac{\partial v}{\partial x} 
+ v\frac{\partial v}{\partial y}\right) - \frac{\partial P}{\partial 
y} + 
\frac{1}{Re}\left(\frac{\partial^2v}{\partial x^2} + 
\frac{\partial^2v}{\partial y^2}\right)
&\hspace{8ex}
\mbox{direção y}
\\\label{eq:cm}
\frac{\partial u}{\partial x} + \frac{\partial v}{\partial y} = 0
\hspace{17.8ex}&\hspace{8ex}\mbox{continuidade}
\end{align}
\end{document}

enter image description here

2

With a trick similar to the one in https://tex.stackexchange.com/a/209732/4427

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsmath}

\newcommand{\pder}[3][]{%
  \frac{\partial^{#1} #2}{\partial #3^{#1}}%
}

\makeatletter
\newcommand{\colwidth@}[1]{%
  \ifcase\expandafter#1\maxcolumn@widths\fi
}
\newcommand{\Cen}[1]{%
  \ifmeasuring@
  \else
    \makebox[0pt][l]{%
      \kern-\colwidth@{1}%
      \makebox[\dimexpr\colwidth@{1}+\colwidth@{2}]{$\displaystyle#1$}%
    }%
  \fi&
}
\makeatother


\begin{document}

\begin{align}
\label{eq:mx}
\pder{u}{t} &= - \left(u\pder{u}{x} + v\pder{u}{y}\right) - \pder{P}{x} + 
\frac{1}{Re}\left(\pder[2]{u}{x} + \pder[2]{u}{y}\right)
&&
\text{direção $x$}
\\
\label{eq:my}
\pder{v}{t} &= - \left(u\pder{v}{x} + v\pder{v}{y}\right) - \pder{P}{y} + 
\frac{1}{Re}\left(\pder[2]{v}{x} + \pder[2]{v}{y}\right)
&&
\text{direção $y$}
\\
\label{eq:cm}
\Cen{\pder{u}{x} + \pder{v}{y} = 0}
&&\text{continuidade}
\end{align}

\end{document}

enter image description here

Alternative, without centering the last line:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsmath}

\newcommand{\pder}[3][]{%
  \frac{\partial^{#1} #2}{\partial #3^{#1}}%
}

\begin{document}

\begin{align}
\label{eq:mx}
\pder{u}{t} &= - \left(u\pder{u}{x} + v\pder{u}{y}\right) - \pder{P}{x} + 
\frac{1}{Re}\left(\pder[2]{u}{x} + \pder[2]{u}{y}\right)
&&
\text{direção $x$}
\\
\label{eq:my}
\pder{v}{t} &= - \left(u\pder{v}{x} + v\pder{v}{y}\right) - \pder{P}{y} + 
\frac{1}{Re}\left(\pder[2]{v}{x} + \pder[2]{v}{y}\right)
&&
\text{direção $y$}
\\
\label{eq:cm}
\pder{u}{x} &+ \pder{v}{y} = 0
&&\text{continuidade}
\end{align}

\end{document}

enter image description here

An alternative approach is with IEEEeqnarray of IEEEtrantools:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsmath}
\usepackage{IEEEtrantools}

\newcommand{\pder}[3][]{%
  \frac{\partial^{#1} #2}{\partial #3^{#1}}%
}

\begin{document}

\begin{IEEEeqnarray}{rCl'l}
\label{eq:mx}
\pder{u}{t} &=& - \left(u\pder{u}{x} + v\pder{u}{y}\right) - \pder{P}{x} + 
\frac{1}{Re}\left(\pder[2]{u}{x} + \pder[2]{u}{y}\right)
&
\text{direção $x$}
\\
\label{eq:my}
\pder{v}{t} &=& - \left(u\pder{v}{x} + v\pder{v}{y}\right) - \pder{P}{y} + 
\frac{1}{Re}\left(\pder[2]{v}{x} + \pder[2]{v}{y}\right)
&
\text{direção $y$}
\\
\IEEEeqnarraymulticol{3}{c}{\pder{u}{x} + \pder{v}{y} = 0}
&\text{continuidade}
\label{eq:cm}
\end{IEEEeqnarray}

\end{document}

enter image description here

egreg
  • 1,121,712
2

I propose these variants based on flalign:

\documentclass[brazil]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{esdiff}

\begin{document}

\begin{flalign}
\label{eq:mx}
 & & \diffp{u}{t}= - \left(u\diffp{u}{x} + v\diffp{u}{y}\right)& - \diffp{P}{x} +
\frac{1}{Re}\left(\diffp[2]{u}{x} + \diffp[2]{u}{y}\right)
&&
\text{\small direção $x$} \\[0.5ex]
\label{eq:my}
 & & \diffp{v}{t}= - \left(u\diffp{v}{x} + v\diffp{v}{y}\right) &- \diffp{P}{y} +
\frac{1}{Re}\left(\diffp[2]{v}{x} + \diffp[2]{v}{y}\right)
&&
\text{\small direção $y$} \\[0.5ex]
\label{eq:cm}
 & & \diffp{u}{x}& + \diffp{v}{y} = 0
& &\text{\small continuidade}
\end{flalign}

\begin{flalign}
\label{eq:mx}
 & & \diffp{u}{t}= - \left(u\diffp{u}{x} + v\diffp{u}{y}\right)& - \diffp{P}{x} +
\frac{1}{Re}\left(\diffp[2]{u}{x} + \diffp[2]{u}{y}\right)
&
\text{\small direção $x$}& \\[0.5ex]
\label{eq:my}
 & & \diffp{v}{t}= - \left(u\diffp{v}{x} + v\diffp{v}{y}\right) &- \diffp{P}{y} +
\frac{1}{Re}\left(\diffp[2]{v}{x} + \diffp[2]{v}{y}\right)
&
\text{\small direção $y$}& \\[0.5ex]
\label{eq:cm}
 & & \diffp{u}{x}& + \diffp{v}{y} = 0
&\text{\small continuidade} &
\end{flalign}

\end{document}

enter image description here

Bernard
  • 271,350
0

Compile the following at least twice on the first go:

enter image description here

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{amsmath,eqparbox}

\begin{document}

\begin{align}
  \eqmakebox[LHS]{$\displaystyle\frac{\partial u}{\partial t} =
    - \left(u\frac{\partial u}{\partial x} 
    + v\frac{\partial u}{\partial y}\right) - \frac{\partial P}{\partial x}
    + \frac{1}{Re}\left(\frac{\partial^2u}{\partial x^2}
    + \frac{\partial^2u}{\partial y^2}\right)$} &&&
  \text{direção $x$} \\
  \eqmakebox[LHS]{$\displaystyle\frac{\partial v}{\partial t} = 
    - \left(u\frac{\partial v}{\partial x} 
    + v\frac{\partial v}{\partial y}\right) - \frac{\partial P}{\partial y} 
    + \frac{1}{Re}\left(\frac{\partial^2v}{\partial x^2} 
    + \frac{\partial^2v}{\partial y^2}\right)$} &&&
  \text{direção $y$} \\
  \eqmakebox[LHS]{$\displaystyle\frac{\partial u}{\partial x} 
    + \frac{\partial v}{\partial y} = 0$} &&&
  \text{continuidade}
\end{align}

\end{document}

The package eqparbox ensures that all \eqmakebox[<tag>] with the same <tag> have the same maximum width. The default is to centre the content within these boxes, although you can change that alignment (\eqmakebox[<tag>][<align>]).

Werner
  • 603,163
  • This relies on the fact that u and v have the same width; with w it wouldn't work. – egreg Oct 27 '17 at 17:44
  • @egreg: I don't understand... – Werner Oct 27 '17 at 17:46
  • Try replacing the first \partial u with \partial uuuuu and you'll see what I mean; but already \partial w shows the issue. – egreg Oct 27 '17 at 20:22
  • @egreg: I know you're referencing the fact that the first two equations currently line up at the =, but that's not a requirement in the question. The OP explicitly mentions that "[the] equations can stay in the same position as in the figure.". So, alignment around = was explicitly avoided in my answer (not the use of &&&... – Werner Oct 27 '17 at 22:18