LaTeX forum ⇒ Text FormattingRestore Centering for Equations in custom Class

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

Restore Centering for Equations in custom Class

Postby BinaryBen » Thu Feb 21, 2013 5:06 pm

Hi,

I've got a template, and in the class file (*.cls) it has:
  1. \AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%

I want to override this and restore equation centering -
I can do:
  1. \makeatletter
  2. \setlength{\@mathmargin}{50pt}
  3. \makeatother

Which indents it - however, online it says the default is \@centering. I've tried this.
  1. \makeatletter
  2. \setlength{\@mathmargin}{\@centering}
  3. \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.

Tags:

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

Postby kaiserkarl13 » Thu Feb 21, 2013 8:48 pm

The following code does not reproduce your problem:
  1. \documentclass{article}
  2. \usepackage{amsmath}
  3.  
  4. \makeatletter
  5. \AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%
  6. \makeatother
  7.  
  8. \begin{document}
  9. \begin{equation}
  10. a x^2 + bx + c = 0
  11. \end{equation}
  12. \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

Postby BinaryBen » Sun Feb 24, 2013 9:37 pm

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

  1. \documentclass[twocolumn]{svjour3}


which contains the command:
  1. \AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%


Thanx

Ben
Last edited by cgnieder on Sun Feb 24, 2013 10:19 pm, edited 1 time in total.
Reason: added code markup

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Postby svend_tveskaeg » Sun Feb 24, 2013 10:11 pm

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: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Sun Feb 24, 2013 10:24 pm

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
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

User avatar
Stefan Kottwitz
Site Admin
Posts: 8979
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun Feb 24, 2013 10:26 pm

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
Site admin

jhargis
Posts: 2
Joined: Wed Feb 26, 2014 12:55 am

Postby jhargis » Wed Feb 26, 2014 1:05 am

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

  1. \documentclass[twocolumn]{svjour3}
  2. \usepackage{amsmath}
  3.  
  4. \makeatletter
  5. \AtBeginDocument{\@ifpackageloaded{amsmath}{\@mathmargin\z@}{}}%
  6. \makeatother
  7.  
  8. \begin{document}
  9. \begin{equation}
  10. 6x=2
  11. \end{equation}
  12. \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.
Reason: changed code markup from inline to block

jhargis
Posts: 2
Joined: Wed Feb 26, 2014 12:55 am

Postby jhargis » Wed Feb 26, 2014 1:18 am

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

Postby mandrake » Tue Jan 20, 2015 3:57 pm

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: 3803
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Jan 20, 2015 5:36 pm

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.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 7 guests