Math & Science ⇒ Centered Equation aligned with a Line of Text
Centered Equation aligned with a Line of Text
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 ?
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
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Centered Equation aligned with a Line of Text
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
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Centered Equation aligned with a Line of Text
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.
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10