Text FormattingRestore Centering for Equations in custom Class

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
BinaryBen
Posts: 15
Joined: Mon Feb 18, 2013 8:54 pm

Restore Centering for Equations in custom Class

Post by BinaryBen »

Hi,

I've got a template, and in the class file (*.cls) it has:

Code: Select all

\AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%
I want to override this and restore equation centering -
I can do:

Code: Select all

\makeatletter
\setlength{\@mathmargin}{50pt}
\makeatother
Which indents it - however, online it says the default is \@centering. I've tried this.

Code: Select all

\makeatletter
\setlength{\@mathmargin}{\@centering}
\makeatother
Although, this seems to do nothing - still fully left aligned.

Am I missing something? Can I restore equation centering?

Thanks,
Last edited by Stefan Kottwitz on Thu Feb 21, 2013 5:29 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Restore Centering for Equations in custom Class

Post by kaiserkarl13 »

The following code does not reproduce your problem:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%
\makeatother

\begin{document}
\begin{equation}
   a x^2 + bx + c = 0
\end{equation}
\end{document}
It is something else in the document class that is determining this behavior. Please post a Infominimal working example to proceed further. Even the name of the document class you're using (or even the name of the class it is based on, if there is such a thing) would help.
BinaryBen
Posts: 15
Joined: Mon Feb 18, 2013 8:54 pm

Restore Centering for Equations in custom Class

Post by BinaryBen »

My example is using the svjour3 class, e.g.:

Code: Select all

\documentclass[twocolumn]{svjour3}
which contains the command:

Code: Select all

\AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%
Thanx

Ben
Last edited by cgnieder on Sun Feb 24, 2013 10:19 pm, edited 1 time in total.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Restore Centering for Equations in custom Class

Post by svend_tveskaeg »

Where is the minimal working example as kaiserkarl13 asked for?
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Restore Centering for Equations in custom Class

Post by cgnieder »

Hi.

svjour3 is not a standard class and is for example not part of a TeX Live installation. It would be very helpful if you could do two things:
  1. attach the class file to your next post so we can download it
  2. adapt kaiserkarl's MWE (Infominimal working example) to one that shows the unwanted behaviour so we can immediately reproduce the issue.
If you do these things I'm confident an answer can be found.

Regards
site moderator & package author
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Restore Centering for Equations in custom Class

Post by Stefan Kottwitz »

Hi Ben,

when I tested it, also with svjour3 the problem doesn't happen. So there's something in your code which you did not show. Please have a look at the web site Karl and Svend linked to, to learn why a minimal example is important and nearly a guarantee for getting a solution.

Stefan
LaTeX.org admin
jhargis
Posts: 2
Joined: Wed Feb 26, 2014 12:55 am

Restore Centering for Equations in custom Class

Post by jhargis »

I'm having the same problem and came upon this thread. My minimum working example is as follows:

Code: Select all

\documentclass[twocolumn]{svjour3}
\usepackage{amsmath}

\makeatletter
\AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%
\makeatother

\begin{document}
\begin{equation}
6x=2
\end{equation}
\end{document}
After doing this, I too can't get the equation to be centered. The equation centers fine if in single column mode, but not in two column mode. Any thoughts?
Last edited by cgnieder on Wed Feb 26, 2014 1:07 am, edited 1 time in total.
jhargis
Posts: 2
Joined: Wed Feb 26, 2014 12:55 am

Re: Restore Centering for Equations in custom Class

Post by jhargis »

Actually, I also just found the solution (well, sort of). I went into the svjour3 cls file and found where the equations in two column mode are default set "fleqn" (line 42 of the code I believe). Just delete the "fleqn" inside the curly brackets , {}, and you'll get centered equations. Again, this is in the svjour3 style file itself that this must be done.

Good luck...
mandrake
Posts: 1
Joined: Tue Jan 20, 2015 3:19 pm

Re: Restore Centering for Equations in custom Class

Post by mandrake »

I got the same issue with equation environment. In two-column document it does not center properly, in one-column document it stays fine. Deleting 'fleqn' from line #42 in svjour3.cls helps, thank you. Do you have any idea whether this can be solved within the source .tex? It is not a problem if I compile the document myself with my own svjour3.cls, but if the journal administration does it, I won't be sure whether they will use svjour3.cls with 'fleqn' removed. I will contact the publisher on this but I'm not sure how fast they will respond on such request.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Restore Centering for Equations in custom Class

Post by Johannes_B »

This is a journal you are tallking about, every article in that journal is suppossed to have a uniform look, so i don't think they will be open for discussion.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply