Math & ScienceEquation not centered

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Equation not centered

Post by Cham »

I have a small problem with some equations in display mode. Sometimes, the equation and its number on the right are large, so LaTeX displaces the equation to the left (small offset). This is a good behavior so the large equation doesn't overlap the number label on its right.

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 ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Equation not centered

Post by localghost »

By now you should know that for an adequate problem description a proper minimal example is essential in such cases.


Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Equation not centered

Post by Cham »

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.

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}
I would like the equation to stay centered, even if the number on its right gets large.
Last edited by Cham on Fri Oct 12, 2012 6:29 pm, edited 5 times in total.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Equation not centered

Post by localghost »

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.
OK, if you think so. But I'm not able to help you without more information. Perhaps somebody else is.

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.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Equation not centered

Post by Stefan Kottwitz »

Hi Cham,

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.
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Equation not centered

Post by Cham »

I just added a complete example in my previous message. That example shows the "problem" I'm describing.

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).
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Equation not centered

Post by Stefan Kottwitz »

Cham wrote:I don't think that my problem need a minimal example. I'm just asking for a feature command.
People often think so. Just be aware:
  • 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.
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.

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Equation not centered

Post by Stefan Kottwitz »

Cham wrote:After all, maybe there isn't any such command ?
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.

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Equation not centered

Post by Cham »

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.
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.

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).
Last edited by Cham on Fri Oct 12, 2012 6:50 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Equation not centered

Post by Stefan Kottwitz »

Cham wrote:EDIT : The equation isn't THAT large (it stays within the text).
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.

Well, try to use the \makebox way:

Code: Select all

\begin{equation}
  \makebox[0pt]{\text{SOME VERY VERY LONG AND LARGE EQUATION}}
\end{equation}
Works well for me.

Stefan
LaTeX.org admin
Post Reply