Math & Science ⇒ Equation not centered
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Equation not centered
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
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
Equation not centered
Well, you don't have to but if you look at the definition ofCham wrote:Hmmm, yes. But I must admit that I'm pretty nervous about modifying my preamble, because my document is now so large and complex, I don't want to mess with this huge castle of cards.cgnieder wrote: You can replace this withIt has the same effect.Code: Select all
\numberwithin{equation}{section}
Changing just a single line of code in the preamble may have HUGE consequences on the whole document.
\numberwithin
you'll see that it does exactly the same except for checking if the counters exist.
Code: Select all
\newcommand{\numberwithin}[3][\arabic]{%
\@ifundefined{c@#2}{\@nocounterr{#2}}{%
\@ifundefined{c@#3}{\@nocnterr{#3}}{%
\@addtoreset{#2}{#3}%
\@xp\xdef\csname the#2\endcsname{%
\@xp\@nx\csname the#3\endcsname .\@nx#1{#2}}}}%
}
\@xp
is an alias for \expandafter
and \@nx
another one for \noexpand
.Regards
Equation not centered
Hmm, this is what makes me a bit nervous. What does this implies ?cgnieder wrote:that it does exactly the same except for checking if the counters exist.
I don't think this should be a concern in my case, but...
Equation not centered
\numberwithin{equation}{section}
it checks for the counters equation
and section
. Since both exist nothing happens. But as I said: you don't have to replace your code. Since it is the same it really doesn't matter.Regards
Equation not centered

I consider my issue solved.

EDIT : Hmmm, not exactly. There's still a glitch, described in my next message below...
Equation not centered
Adding \noindent doesn't do anything.
What is happening here ?
Code: Select all
\documentclass{book}
\usepackage{mathtools}
\usepackage{tensor}
\newtagform{nospace}[\llap\bgroup(]{}{\egroup)}
\numberwithin{equation}{section}
\usepackage[nopar]{lipsum}% for dummy text
\begin{document}
\chapter{Blah}
\section{Blub}
\lipsum[4]
\usetagform{nospace}
\begin{equation}
\frac{d^2 \, \displaystyle{\tensor{x}{^{\lambda}}}}{d\, \sigma^2} +
\Gamma_{\mu \nu}^{\lambda} \; \frac{d\, \displaystyle{\tensor{x}{^{\mu}}}}{d\, \sigma} \,
\frac{d\, \displaystyle{\tensor{x}{^{\nu}}}}{d\, \sigma} =
\frac{d\, \displaystyle{\tensor{x}{^{\lambda}}}}{d\, \sigma} \,
\frac{d\, }{d\, \sigma} \, \ln \sqrt{\, \tensor{g}{_{\mu \nu}} \;
\frac{d\, \displaystyle{\tensor{x}{^{\mu}}}}{d\, \sigma} \,
\frac{d\, \displaystyle{\tensor{x}{^{\nu}}}}{d\, \sigma}}.
\end{equation}
\usetagform{default}
\lipsum[4]
\begin{equation}
\tensor{g}{_{\mu \nu}} \; \frac{d\, \displaystyle{\tensor{x}{^{\mu}}}}{d\, \sigma} \,
\frac{d\, \displaystyle{\tensor{x}{^{\nu}}}}{d\, \sigma} =
\tensor{g}{_{\mu \nu}} \; \frac{d\, \displaystyle{\tensor{x}{^{\mu}}}}{d\, \tau} \,
\frac{d\, \displaystyle{\tensor{x}{^{\nu}}}}{d\, \tau} \,
\Big( \, \frac{d\, \tau}{d\, \sigma} \Big)^{\! 2} \equiv
\Big( \, \frac{d\, \tau}{d\, \sigma} \Big)^{\! 2}.
\end{equation}
\lipsum[4]
\end{document}
Equation not centered
Code: Select all
\usetagform{default}%
Code: Select all
\usetagform{default}
Some text
Code: Select all
\usetagform{default} Some text
Equation not centered

Then this brings me another question, about the % at the end of the command line :
I believed that the % was used only to add some comments to the code, like this :
Code: Select all
\noindent % A comment about this command
Some text...
Equation not centered
\par
token is inserted). This is why
Code: Select all
\usetagform{default}%
Some text
Code: Select all
\usetagform{default}Some text
Code: Select all
\usetagform{default}
Some text
Code: Select all
\usetagform{default} Some text
Code: Select all
\usetagform{default}
Some text
Code: Select all
\usetagform{default}\par Some text
Re: Equation not centered
The case is now fully solved.