Very often, I would like to write an equation after a line of text, with the equation on the same line as the text while horizontally centered on the page and its eq:number appearing on the right side. I don't want LaTeX to reduce the size of the equation, since there's just a single line of text on the same line as the equation. How is that possible ?
To be clear, here's an example of what I would like to do (this was done with an old word processor) :
How to tell LaTeX that the integral should be on the same baseline as the text on its left (I hand added a red horizontal bar on the picture, as a reference), while staying aligned with the equation below it, and no vertical compression at all ?
Math & Science ⇒ Centered Equation aligned with a Line of Text
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Centered Equation aligned with a Line of Text
It can be done with some negative vertical space. But from my point of view it doesn't look really good.
The disadvantage is that you have to adjust this vertical space by hand. I would prefer the common layout, that is to say all the equations aligned with some short text between them.
Thorsten
Code: Select all
\documentclass[11pt,a4paper,french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{geometry}
\usepackage{mathtools} % loads »amsmath«
\let\vec\mathbf % Change appearance of vectors, try \underline here instead of \mathbf
\begin{document}
de référence arbitraire situé dans la distribution. Le potentiel scalaire peut s'écrire comme suit:
\begin{align}
\phi(\vec{r}) &\approx \phi(\vec{r}_0)+(\vec{r}-\vec{r}_0)\cdot\nabla\phi(\vec{r})\big|_{r_0} \\
&= \phi(\vec{r}_0)+\vec{r}_0\cdot\vec{E}(\vec{r})-\vec{r}\cdot\vec{E}(\vec{r}) \\
\end{align}
Ainsi, on a\vspace{-2.15\baselineskip}
\begin{align}
U &\approx \int \bigl(\phi(\vec{r}_0)+\vec{r}_0\cdot\vec{E}(\vec{r})-\vec{r}\cdot\vec{E}(\vec{r})\bigr)\rho\,d^3x \\
&= \bigl(\phi(\vec{r}_0)+\vec{r}_0\cdot\vec{E}(\vec{r}_0)\bigr)\int\rho\,d^3x-\int\rho\,\vec{r}\cdot\vec{E}(\vec{r}_0)\,d^3x
\end{align}
La première intégrale s'élimine pour les distributions caracterisées par une charge électrique totale null.
\end{document}
Code: Select all
\documentclass[11pt,a4paper,french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{geometry}
\usepackage{mathtools}
\let\vec\mathbf % Change appearance of vectors, try \underline here instead of \mathbf
\begin{document}
de référence arbitraire situé dans la distribution. Le potentiel scalaire peut s'écrire comme suit:
\begin{align}
\phi(\vec{r}) &\approx \phi(\vec{r}_0)+(\vec{r}-\vec{r}_0)\cdot\nabla\phi(\vec{r})\big|_{r_0} \\
&= \phi(\vec{r}_0)+\vec{r}_0\cdot\vec{E}(\vec{r})-\vec{r}\cdot\vec{E}(\vec{r}) \\
\shortintertext{Ainsi, on a}
U &\approx \int \bigl(\phi(\vec{r}_0)+\vec{r}_0\cdot\vec{E}(\vec{r})-\vec{r}\cdot\vec{E}(\vec{r})\bigr)\rho\,d^3x \\
&= \bigl(\phi(\vec{r}_0)+\vec{r}_0\cdot\vec{E}(\vec{r}_0)\bigr)\int\rho\,d^3x-\int\rho\,\vec{r}\cdot\vec{E}(\vec{r}_0)\,d^3x
\end{align}
La première intégrale s'élimine pour les distributions caracterisées par une charge électrique totale null.
\end{document}
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Centered Equation aligned with a Line of Text
I agree that we shouldn't adjust the vertical position by hand, so the first solution isn't satisfying.
In the case of the second solution, the inserted short text isn't aligned with the integral equation. After a compilation on my system, it appears at the standard position with the equation below it.
In the case of the second solution, the inserted short text isn't aligned with the integral equation. After a compilation on my system, it appears at the standard position with the equation below it.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Centered Equation aligned with a Line of Text
I know. I don't consider the layout of word processors as benchmark. This is my share. And I can't offer alternatives.Cham wrote:[…] In the case of the second solution, the inserted short text isn't aligned with the integral equation. After a compilation on my system, it appears at the standard position with the equation below it.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10