3

I consider myself a relatively experienced latex user. I am looking for best practices for math mode in LaTeX. Looking around the exchange I couldn't find a post that captures this question broadly. Specifically, I am looking for recommendations and best practice guidelines for things such as:

  1. What is the right way to wrap a sum formula with parenthesis / curly brackets? Do you include the sub / sup parts or not?

    \documentclass{standalone}
    \begin{document}
    
    $$ \left\{\sum_{s\in T}s \Bigm| T \subseteq S\right\} $$
    
    $$ \Bigl\{\sum_{s\in T}s \Bigm| T \subseteq S\Bigr\} $$
    
    \end{document}
    

enter image description here

  1. Should one always include punctuation (comma in the example) after a centered equation?

    \documentclass{standalone}
    \begin{document}
    
    $$ S = \{s_1, \ldots, s_n\}, $$
    
    \end{document}
    

    enter image description here

  2. Do you try to increase the size of parentheses / brackets when you are surrounding a square root environment? If so, do you simply let latex automatically adjust the sizes with \left and \right or do you manually adjust by picking the size yourself?

    \documentclass{standalone}
    \begin{document}
    
    $$ O(\sqrt{n}) $$
    
    $$ O\left(\sqrt{n}\right) $$
    
    $$ O\bigl(\sqrt{n}\bigr) $$
    
    \end{document}
    

    enter image description here

  3. Is it considered bad practice to manually change spacing via \!, or \, type commands?

    \documentclass{standalone}
    \begin{document}
    
    $$ O\left(\max\left\{\frac{\log n }{nm}\right\}^{n}\right) $$
    
    $$ O\!\left(\!\max\left\{\frac{\log n }{n\,m}\right\}^{\!n}\right) $$
    
    \end{document}
    

enter image description here

  1. The eternal divide between in-line a/b vs \frac{a}{b}:

    \documentclass{standalone}
    \begin{document}
    
    Sometime something $a/b$ someplace somewhat.
    
    Sometime something $\frac{a}{b}$ someplace somewhat. 
    
    \end{document}
    

enter image description here

These are just some of the questions that come to mind right now, but this is the general spirit. I would love to have a resource with a compilation of such best practices. By the way, I am sure some of these questions have been answered here somewhere, with this post I am not only interested in the answers to these questions.

kxk
  • 131
  • 5
    First of all: Do not use $$! – TeXnician Jun 24 '18 at 17:13
  • Haha @TeXnician, great point. I was just reading the long discussion about it, but I just happened to be writing my examples in a \documentclass[letterpaper,USenglish]{oasics-v2018} template and interestingly enough \[ \] does not center equations like $$ $$ does. Not sure why, didn't look into it, I just used $$ $$ but I will remember to use \[ \] and \( \) in the future! Thank you! – kxk Jun 24 '18 at 17:16
  • 3
    in addition (and more important) than not using $$ never leave a blank line before a math display. – David Carlisle Jun 24 '18 at 17:33
  • @DavidCarlisle: Can you elaborate on this point? I actually did not know that. I usually leave a blank line to make the .tex file more "readable". Why is this a bad practice? – kxk Jun 24 '18 at 17:34
  • 5
    It completely messes up the spacing making a spurious "white" paragraph before the display. – David Carlisle Jun 24 '18 at 17:37
  • 1
    @DavidCarlisle I never knew that. This is exactly the sort of information I am looking for. Thank you Sir! – kxk Jun 24 '18 at 17:38
  • 3
    see for example https://tex.stackexchange.com/a/298141/1090 – David Carlisle Jun 24 '18 at 17:38
  • 3
    it is almost always better to use a fixed size such as \bigl rather than \left if you know the size in advance and if you do that many of the negative space fixes you show are not needed. – David Carlisle Jun 24 '18 at 17:40
  • 2
    You say \[ doesn't center the way $$ does, that is because you are using a document class that specifies left aligned equations, but $$ does not honour the document class setting as it is not a supported latex construct. – David Carlisle Jun 24 '18 at 17:45
  • 2
    Isn't this question too broad and partly off-topic? E.g. whether to add a comma after a centred equation seems off-topic. Most of the rest seems too broad. (What are the criteria for a satisfactory answer?) The site works best when you have one question per question and not four or more .... – cfr Jun 24 '18 at 17:46
  • 1
    It is ok to use $...$ if you wish, as this is just equivalent to \(...\). It is only $$....$$ which should not be used. – cfr Jun 24 '18 at 17:47
  • 1
    @cfr yes I was just going to suggest that this is too broad. kxk the site works best with one question per question. – David Carlisle Jun 24 '18 at 17:49
  • I understand. If someone is interested in general best practice guidelines like the ones just now discussed, is there a resource either of you would suggest @DavidCarlisle and @cfr? – kxk Jun 24 '18 at 17:50
  • 1
    you are asking for a tutorial not a question/answer site, there are loads of tutorials on the web – David Carlisle Jun 24 '18 at 17:52
  • Is this really a tutorial type of question? I feel like some of these questions are too subtle to be answered in a general tutorial. What I am looking for is more subtle advice / guide-lines. – kxk Jun 24 '18 at 17:54
  • You can only ping one person per comment. The site should have warned you when you tried to ping two of us. – cfr Jun 24 '18 at 18:46
  • There are also books and some electronic guides, some of each specifically on maths mode. And parts of your question are not technical at all, but really to do with typographic norms, which may even vary by discipline, publisher etc. – cfr Jun 24 '18 at 18:49
  • @cfr :Can you provide any of these resources? – kxk Jun 24 '18 at 18:51
  • Look at the questions on learning LaTeX and/or search CTAN. There's a question with answers listing books, websites etc. for beginners. I know you're not a beginner, but many of these resources, while introducing the system, go considerably beyond the beginner level. – cfr Jun 24 '18 at 18:56
  • 1
    E.g. see https://tex.stackexchange.com/a/30/. – cfr Jun 24 '18 at 18:57

0 Answers0