0

I've recently converted to using \[ \] instead of $$ $$ as my begin/end math command since I read that is the "correct" method. However, the backslash character is near my pinky on my keyboard and typing that every single line is getting my pinky fatigued.

Is there some sort of multiline equation command/environment in LaTeX similar to how many programming languages have multiline comments?

That is, I currently have:

\[ r \approx R_{\odot}/2 \]
\[ T \approx 10^{7} K \]
\[ M \approx \frac{1}{2} M_{\odot} \]
\[ l \approx R_{\odot}/20 \]
\[ H = \frac{L_{\odot}}{4 \pi r^{2}} \]
\[ \Delta \nabla T \approx 2 \times 10^{-10} \]
\[ \frac{dT}{dr} \approx \frac{\bar{T}}{R_{\odot}} \approx 6 \times 10^{-5} \]

whereas I would like something of the form

\begin{math}
r \approx R_{\odot}/2
T \approx 10^{7} K
M \approx \frac{1}{2} M_{\odot}
l \approx R_{\odot}/20
H = \frac{L_{\odot}}{4 \pi r^{2}}
\Delta \nabla T \approx 2 \times 10^{-10}
\frac{dT}{dr} \approx \frac{\bar{T}}{R_{\odot}} \approx 6 \times 10^{-5}
\end{math}

Please note that amsmath's align and gather don't fit the bill for me since they require two backslashes at the end of each line.

I'm open to source modification solutions.

Also, I'm using the article documentclass (if it matters).

  • 1
    you should never have two display math environments in succession so your first example with multiple ..\]\[... is wrong. It would in theory be possible (but fragile) to make end of line mean \\ in an align but why??? it is only one character less, and you are already entering dozens of \ so \\ is possibly the easiest command to enter. – David Carlisle Mar 6 '16 at 17:50
  • 2
    Well, you have to use your pinky for basically any TeX command -- ;-) – user31729 Mar 6 '16 at 17:50
  • @DavidCarlisle I don't understand what you mean by the first sentence of your comment; it compiles fine for me. It's true you need \ for all the commands but I still think a reduction in the number I have to enter would be nice (and it would remove 4 characters per line, not one). Your mention of modifying align to make end of line mean \\ is essentially what I was thinking of by "open to source modification solutions;" I just wanted to see if people suggested anything different. – Ryan Farber Mar 6 '16 at 19:17
  • 2
    multiple \[\]\[\] does not generate a tex error but the vertical space and page break control around the math will be very poor. using a newline instead of \\ to force a new row in the math does save exactly one character, not four:-) – David Carlisle Mar 6 '16 at 19:25
  • Okay, I think I understand what you mean about the multiple \[ \] issue (though I don't think I've had trouble with it yet). Also, I had meant a "return" will save me four characters in terms of getting rid of the \[ \] on each line. Also, since that newline is there no matter what I still think it would save me two characters rather than one in terms of replacing \\ – Ryan Farber Mar 6 '16 at 21:00
1

I think gathered can help you

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation}
    \begin{gathered}
        r \approx R_{\odot}/2 \\
        T \approx 10^{7} K \\
        M \approx \frac{1}{2} M_{\odot} \\
        l \approx R_{\odot}/20 \\
        H = \frac{L_{\odot}}{4 \pi r^{2}} \\
        \Delta \nabla T \approx 2 \times 10^{-10} \\
        \frac{dT}{dr} \approx \frac{\bar{T}}{R_{\odot}} \approx 6 \times 10^{-5}
    \end{gathered}
\end{equation}

\end{document}

I do agree with comments because \\ are necessary in LaTeX. You will take the habits :)

| improve this answer | |
1

This solves two problems at once: first, not typing \[...\] over and over, and second, having a neat alignment. Try using the align env:

    \begin{align}
        r \approx R_{\odot}/2 \\
        T \approx 10^{7} K \\
        M \approx \frac{1}{2} M_{\odot} \\
        l \approx R_{\odot}/20 \\
        H = \frac{L_{\odot}}{4 \pi r^{2}} \\
        \Delta \nabla T \approx 2 \times 10^{-10} \\
        \frac{dT}{dr} \approx \frac{\bar{T}}{R_{\odot}} \approx 6 \times 10^{-5} \\
    \end{align}

Now, insert the & symbol where you want it to align. This creates a very nice arrangement! For example, why not try this:

    \begin{align}
        &r \approx R_{\odot}/2 \\
        &T \approx 10^{7} K \\
        &M \approx \frac{1}{2} M_{\odot} \\
        &l \approx R_{\odot}/20 \\
        &H = \frac{L_{\odot}}{4 \pi r^{2}} \\
        &\Delta \nabla T \approx 2 \times 10^{-10} \\
        &\frac{dT}{dr} \approx \frac{\bar{T}}{R_{\odot}} \approx 6 \times 10^{-5} \\
    \end{align}

This will align everything on the left. Put all the &s to the right for a right align, or mix things up by adding &s in the middle. In general, all equations will shift until the &s line up, then hide the &s.

| improve this answer | |
  • The original question states that the double backslash isn't wanted either, hence align isn't acceptable. – barbara beeton Mar 19 at 19:41
  • 1
    In LaTeX, you normally have to use either \newline or \\. It's very hard to find cases where you don't need those. – Someone Mar 21 at 19:08
  • Anyway, simply typing \\ at the end of each line is far better than typing \[...\] each time. – Someone Apr 3 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.