Math & Science ⇒ Equation not centered
Re: Equation not centered
Is there a way to "smash" the tag number ?
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
Equation not centered
Most can be redefined and patched, also tagging macros. Just be aware, that redefining internal macros can mean that it doesn't work with future packages releases which decide to change internal macros. Well, it would work now. So, one way of horizontal smashing is using
Stefan
\makebox
with a value of 0pt
. With 0pt
we get a line break though, but let's choose the smallest TeX unit and it works. Just insert right before your \makeatother
:Code: Select all
\renewcommand*{\maketag@@@}[1]{\hbox{\m@th\normalfont{\makebox[1sp][r]{#1}}}}
LaTeX.org admin
Re: Equation not centered
Thanks Stefan, this works.
Unfortunately, it may cause problems with lots of other equations (I didn't checked yet).
Is there a way to achieve the same effect on a particular equation, without affecting the others ?
Unfortunately, it may cause problems with lots of other equations (I didn't checked yet).
Is there a way to achieve the same effect on a particular equation, without affecting the others ?
Equation not centered
OUCH !
Stefan, your modification affects all the equation references in the text. Just add a
Stefan, your modification affects all the equation references in the text. Just add a
\label{}
to an equation and use \eqref{}
in the text, and it will be messed-up !
Last edited by cgnieder on Sun Oct 14, 2012 4:35 pm, edited 1 time in total.
Equation not centered
How about this: use mathtools instead of amsmath (the first loads the latter anyway) and define a tagform
I could imagine that this works for all tags but even if it doesn't you could switch back and forth with
Here is a complete example (also note that I change the equation counter with amsmath's
Regards
nospace
:Code: Select all
\newtagform{nospace}[\llap\bgroup(]{}{\egroup)}
\usetagform
.Here is a complete example (also note that I change the equation counter with amsmath's
\numberwithin
):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}
site moderator & package author
Re: Equation not centered
Note: this will also affect a possible reference to the equation.
site moderator & package author
Equation not centered
Thanks cgnieder, your solution appears to work very well.
Since I'm already using the mathtools package in my real document, I may simply add this code to the preamble :
just under my usual tag modification :
Then using
Since I'm already using the mathtools package in my real document, I may simply add this code to the preamble :
Code: Select all
\newtagform{nospace}[\llap\bgroup(]{}{\egroup)}
Code: Select all
\makeatletter
\renewcommand\theequation{\thesection.\arabic{equation}}
\@addtoreset{equation}{section}
\makeatother
\usetagform{nospace}
and \usetagform{default}
around a special equation solves the issue for that particular equation. All other equations are left untouched.
Last edited by Cham on Sun Oct 14, 2012 4:55 pm, edited 2 times in total.
Equation not centered
You can replace this withCham wrote:just under my usual tag modification :Code: Select all
\makeatletter \renewcommand\theequation{\thesection.\arabic{equation}} \@addtoreset{equation}{section} \makeatother
Code: Select all
\numberwithin{equation}{section}
Regards
site moderator & package author
Equation not centered
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.
Last edited by Cham on Sun Oct 14, 2012 5:09 pm, edited 1 time in total.
Equation not centered
Since I'm no expert in LaTeX coding : Before adopting cgnieder's solution, I would like to hear comments from the other "pros" here about his solution.
Is there any inconvenience about that solution ?
Apparently, it's working very well in my document (but I didn't checked all of the 700 pages yet!), and as I said in my previous message, I'm more and more reluctant to modify my preamble (it's now a huge "castle of cards").
Is there any inconvenience about that solution ?
Apparently, it's working very well in my document (but I didn't checked all of the 700 pages yet!), and as I said in my previous message, I'm more and more reluctant to modify my preamble (it's now a huge "castle of cards").