Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Incorrect spacing and sizing, probably caused by LaTeX template

  1. Nov 7, 2011 #1

    Fredrik

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    For about a year and a half now, I've been writing down stuff I've learned into a bunch of LateX files, to make it easy to refresh my memory when I've forgotten something, and perhaps also to be able to show some of it to other people at some point. In order to make it look nice, I chose to use a template that a publisher provides for their book authors. (If someone wants to see it, it's the "monograph" file that can be downloaded from here). Everything does look really nice, except for two things:

    1. When I use \left and \right to have LaTeX choose the size of parentheses and stuff, they always turn out too big. This also happens when I use the cases environment.

    2. There appears to be a negative space after each mathbb character, so if I e.g. want to end a sentence with "[itex]\mathbb C.[/itex]" have to type it as "\mathbb C\ .", or the period won't be visible.

    These are problems that can be worked around without too much trouble, but I would of course prefer to fix the problem rather than work around it every time. So does anyone have any idea about what might be wrong? I don't even know what to look for. I guess I should look in the .cls file, but look for what?

    This is the stuff at the start of the main LaTeX file.

    Code (Text):

    documentclass[graybox,envcountchap,sectrefs,envcountsame]{svmono}
    \usepackage{mathptmx}
    \usepackage{helvet}
    \usepackage{courier}
    \usepackage{type1cm}        
    \usepackage{makeidx}
    \usepackage{graphicx}
    \usepackage{multicol}
    \usepackage[bottom]{footmisc}
    \usepackage{mathtools}
    \DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}
    \makeindex          
    \usepackage{amsmath,amssymb,enumerate,mathtools}
     
    The DeclareMathAlphabet command is something I found in a Google search. It restores the normal mathcal font, which had been replaced by something else.
     
  2. jcsd
  3. Nov 7, 2011 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    I had a quick look at your document class and it doesn't seem to be redefining any math fonts, though it uses them in lots of places.

    You have several packages that could be trying to redefine the math fonts and fighting each other, e.g. mathptmx, type1cm, mathtools, amsmath, amssymb
    and the \DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n} command.

    I would start by looking at your .log file, to see what math fonts you are actually using.

    The ams... classes on their own should work OK.

    Start with a "plain vanilla" document class like "article" plus the ams... packages and see if that looks OK. If not, then you and LaTeX fundamentally disagree about what "looks right" so you need to find a compromise on that before you add anything else into the mix.

    Then try svmono class with just the asm... packages.

    Then add the other packages one at a time to see what breaks it. Sometimes, the order of loading the packages is significant. Unless a package says internally that it depends on another package, they are loaded in the order they appear in the .tex file.

    The graphicx multicol and footmisc packages shouldn't have any effect on math.

    Re \left and \right, remember they are desgined to make delimiters bigger than everything inside them, which is sometimes too big. For example if you want
    Code (Text):
    [ ... ( ... ) ... ]
    you probably want the [] and () the same size as each other, but
    Code (Text):
    \left[ ... \left( ... \right) ... \right]
    will make the [ ] bigger than the ( ).

    EDIT: If you load amsmath, load amsfonts as well (and weed out any other packages that it makes redundant, of course).
     
    Last edited: Nov 7, 2011
  4. Nov 7, 2011 #3

    Fredrik

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Thanks for the tips. I will try them out tomorrow morning, and report the results here some time during the day.
     
  5. Nov 8, 2011 #4

    Fredrik

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Interesting. I'm getting the same problem with the mathbb font when I just use \documentclass{article} and \usepackage{amssymb}. (Without amssymb, the \mathbb command is not understood). The mathbb font appears to be different mathbb font than the one that's used here:

    [itex]\mathbb C.\mathbb N.\mathbb Q.\mathbb R.\mathbb F.[/itex]

    My mathbb characters have serifs, and the "tail" on the Q consists of two curves meeting at a point, not a single curve as here on PF. Edit: I tried changing amssymb to amsfonts. It didn't change anything.

    I may have exaggerated the problem with the mathbb fonts somewhat. Only the C is really messed up. With the other symbols, a period after a mathbb character is a bit too close to the character, but with the C, it's actually on the C, to the left of the point where the C ends.

    Regarding the left/right issue, I may have made a bigger mistake there. For example, even here at PF, the left/right parentheses surrounding a sum is big enough to cover the limits both over and under the Ʃ, even if there is no upper limit. For example: [tex]\left(\sum_{i\in I} P_i\right)x[/tex]
    So maybe the only problem was my expectations. I'm still not sure. Right now I can't think of a situation where \left and \right definitely give me the wrong sizes. However, I did get weird results when I wrote this:
    [tex]\sum_{i\in I}P_ix=
    \begin{cases}
    x &\text{if}~x\in M\\
    0 &\text{if}~x\in M^\perp.
    \end{cases}
    [/tex]
    The code requires the amsmath package.
    Code (Text):
    [tex]\sum_{i\in I}P_ix=
    \begin{cases}
    x &\text{if}~x\in M\\
    0 &\text{if}~x\in M^\perp.
    \end{cases}
    [/tex]
    The left curly bracket is a little bigger in my document, but it's not really a problem. I'll either just ignore it or use \left{ with the array environment.
     
    Last edited: Nov 8, 2011
  6. Nov 8, 2011 #5

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    So the good news is, we now know where the problem is, even if we don't know what it is.

    I tried this in MikTeX 2.9:
    Code (Text):

    \documentclass{article}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \begin{document}
    $$\mathbb C. \mathbb N. \mathbb Q. \mathbb R. \mathbb F.$$
    \end{document}
     
    The output looks the same as in your post #4 - no bad spacing. I've attached a copy of my logfile to compare with yours.

    EDIT: I see you didn't load amsmath, but it still works for me without it.

    Yeah, the TeXBook says it does that :(
    Knuth doesn't seem to give a workround, except selecting the delimiter size with one of the the \Big... macros.
    But your problem with \case could be part of the same fonts issue that is screwing up \mathbb of course...


    I guess the only answer is select the size you want with one of the \Big... macros.
     

    Attached Files:

    Last edited: Nov 8, 2011
  7. Nov 8, 2011 #6

    Fredrik

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Oh my dog, the problem is with the built-in dvi viewer. (I'm using the LaTeX editor "LEd"). When I ran LaTeX on your code, the result was ugly. So I ran PDFLaTeX instead, and the result looked fine. Then I ran LaTeX again, and converted the dvi to PDF. It still looked fine. So I opened the dvi file in Yap ("Yet another previewer"). Now the mathbb characters looked fine but other things were ugly. There was e.g. a [itex]\|x\|[/itex] that looked like [itex]\|\,x\!\|[/itex]. In the PDF, those things looked good too.

    Thank you very much for helping me figure this out. At least now I know that I should stop typing a "\ " after every "\mathbb C". :smile:

    The curly bracket produced by "cases" looks the same in the PDF as in the dvi, a little bit bigger than I'd want them to be (and a little bit bigger than at PF), but it doesn't bother me as much as the mathbb issue, so I'm not going to spend any more time thinking about that. Thanks again, you've been a great help.
     
    Last edited: Nov 8, 2011
  8. Nov 8, 2011 #7

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    You just reminded my why I never use a LaTex "IDE", just a text editor that can run an OS command with a single keystroke, and a PDF viewer :smile:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Incorrect spacing and sizing, probably caused by LaTeX template
Loading...