Math & Science ⇒ Equation not centered
Equation not centered
But sometimes, the equation should stay in the middle. How can I tell LaTeX to NOT left-displace the equation ? What is the command to "pin" the equation in the center, whatever how large it is ?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Equation not centered
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Equation not centered
But here's an example anyway. The equation number on the right isn't large, though, and the "equation" has a slight offset to the left :
Code: Select all
\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{amsmath}
\makeatletter
\renewcommand\theequation{\thesection.\arabic{equation}}
\@addtoreset{equation}{section}
\makeatother
\begin{document}
\chapter{Title}
\section{Section title}
\subsection{Subsection}
Bla bla bla bla
\begin{equation}
\text{SOME VERY VERY LONG AND LARGE EQUATION}
\end{equation}
Bla bla bla.
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Equation not centered
OK, if you think so. But I'm not able to help you without more information. Perhaps somebody else is.Cham wrote:localghost, I don't think that my problem need a minimal example. I'm just asking for a feature command. I'm pretty sure this is standard.
Addendum:
The added example is not helpful (for me) because it does not reproduce the undesired behaviour as a proper example should do. Why don't you just post a concrete equation that is affected? You can manipulated the
equation
counter by \setcounter
to get a high equation number.Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Equation not centered
equations are centered by default. It seems, your current situation needs a workaround, depending on the equation environments you use - standard equation, multi-line, eqnarray (which is known for alignment problems when the equation is wide ...). It could even be an error or a mistake, not a feature.
Sure you can get a general answer without an MWE sometimes. Then it's a chance, that it doesn't help in your specific case. So let's try though: you could use
\parbox
or a minipage
environment to put a wide equation centered in a wider box, or \makebox
to give such a box a different width than it naturally has, centering in relation to it.Stefan
PS: posted before you edited and added the example.
Equation not centered
Take note that it isn't a real problem in this case. LaTeX is doing its job very well here. However, in some special cases, I would like to "pin" the equation in the center (no left-offset). How?
I was thinking about a command to add after the
{equation}
declaration, something like \centering
(of course, this one doesn't work). After all, maybe there isn't any such command ?Sorry for the confusion. Overlapping postings at the same moment. See my updated message (with example).
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Equation not centered
People often think so. Just be aware:Cham wrote:I don't think that my problem need a minimal example. I'm just asking for a feature command.
- If you provide an example, which can be used to verify the problem, it's often easy to fix. So there's a high chance to quickly get a solution.
- If you just describe a problem, without a test case, it's rather theoretical. Even if people have an idea, why write that if it cannot be tested and may be not useful in the specific case? Often people don't participate in guessing and suggesting. There's a much smaller chance to get a solution. Most times, it anyway ends in requesting details such as an MWE, and lost time.
Stefan
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Equation not centered
There isn't such a standard command. Equations are already centered by default. Your intention, to let a wider equation symmetrically override margins (as I understand), is not a standard feature, since staying within the text area is the usual way.Cham wrote:After all, maybe there isn't any such command ?
A solution like I described above, is here: Centering wide tables or figures. It may be applied to equations too. But without test code, it's an untested recommendation, so you need to apply it yourself.
Stefan
Equation not centered
The example above DO produce the "problem". The equation isn't centered ; it has a slight offset to the left, so LaTeX prints a nice space between the equation and its number on the right.Stefan_K wrote: The example above doesn't add much value. It is still not a test case, as it doesn't produce the problem. I just recommend: try to make it easy for the people to help you.
This is the usual way to write things. But as I said, I would like to "pin" the equation in the center (no offset to the left) in some special cases only.
EDIT : The equation isn't THAT large (it stays within the text).
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Equation not centered
Ok, as it's not so wide, it's hard to see, as there's no comparable other equation. But one can see it's shifted to the left, compared to a version when we change it to equation*, making it unnumbered.Cham wrote:EDIT : The equation isn't THAT large (it stays within the text).
Well, try to use the
\makebox
way:
Code: Select all
\begin{equation}
\makebox[0pt]{\text{SOME VERY VERY LONG AND LARGE EQUATION}}
\end{equation}
Stefan