LaTeX forum ⇒ Math & SciencePlacing Text Between Equations Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
parkerokabe
Posts: 7
Joined: Thu Apr 25, 2019 5:45 pm

Placing Text Between Equations

Postby parkerokabe » Thu Apr 25, 2019 6:08 pm

Hi everyone! First post. I'm very new to LaTeX and just started a couple of days ago. I'm trying to write a series of equations and I want to place text between them, but when I put the text in math mode it numbers it like an equation. If I put the text outside of the math mode I get a huge gap between the text and equations. For example:

\begin{align}
eqn1 \\[10pt]
eqn2
\end{align}
\begin{center}
or
\end{center}
\begin{align}
eqn3
\end{align}

I'm guessing the spacing has something to do with the template I downloaded. Any help would be great! Thanks!

user22741
Posts: 33
Joined: Fri Nov 09, 2018 12:03 pm

Postby user22741 » Thu Apr 25, 2019 7:03 pm

Are you searching for `\intertext{}`?

  1. \documentclass{article}
  2. \usepackage{mathtools}
  3. \begin{document}
  4.  
  5. \begin{align}
  6. eqn1 \\[10pt]
  7. eqn2\\
  8. \intertext{\centering text}
  9. eqn3
  10. \end{align}
  11.  
  12.  
  13. \end{document}

parkerokabe
Posts: 7
Joined: Thu Apr 25, 2019 5:45 pm

Postby parkerokabe » Thu Apr 25, 2019 9:43 pm

user22741 wrote:Are you searching for `\intertext{}`?

  1. \documentclass{article}
  2. \usepackage{mathtools}
  3. \begin{document}
  4.  
  5. \begin{align}
  6. eqn1 \\[10pt]
  7. eqn2\\
  8. \intertext{\centering text}
  9. eqn3
  10. \end{align}
  11.  
  12.  
  13. \end{document}


Yes, that works great, but is there a way to shorten the distance between the text and equations? It's still obnoxiously large. Thank you for the reply, by the way!

user22741
Posts: 33
Joined: Fri Nov 09, 2018 12:03 pm

Postby user22741 » Thu Apr 25, 2019 10:35 pm

can you show some example code that produces obnoxiously large spacing? I only get the usual above and below display skip in my example.

parkerokabe
Posts: 7
Joined: Thu Apr 25, 2019 5:45 pm

Postby parkerokabe » Thu Apr 25, 2019 11:10 pm

user22741 wrote:can you show some example code that produces obnoxiously large spacing? I only get the usual above and below display skip in my example.


\documentclass[review]{elsarticle}

\usepackage{lineno,hyperref,upgreek,graphicx,chemformula,subfig}
\modulolinenumbers[5]

\begin{document}

\begin{frontmatter}

\begin{align}
\ch{Ce + H_2 -> CeH_2}, \qquad \qquad \Delta &G_{rxn}^\circ=-115 kJ/mol \\[10pt]
\ch{CeH_2 + 2.5Cl_2 -> CeCl_3 + 2HCl}, \qquad \qquad \Delta &G_{rxn}^\circ=-1007 kJ/mol
\intertext{\centering or}
\ch{CeH_2 + 1.5Cl_2 -> CeCl_3 + H_2}, \qquad \qquad \Delta &G_{rxn}^\circ=-812 kJ/mol
\end{align}
\vspace{0.1mm}


Capture.JPG
Capture.JPG (17.09 KiB) Viewed 138 times


The attached picture is what it looks like. It might be the same spacing between each line, but it doesn't look right that the second and third equations are so far apart.

Sorry is that enough code? I'm not exactly sure how to use this forum either... :?

user22741
Posts: 33
Joined: Fri Nov 09, 2018 12:03 pm

Postby user22741 » Thu Apr 25, 2019 11:30 pm

Your output looks just as it should. If you really want to reduce the space:

  1. \documentclass[review]{elsarticle}
  2.  
  3. \usepackage{lineno,hyperref,upgreek,graphicx,chemformula,subfig}
  4. \modulolinenumbers[5]
  5.  
  6. \begin{document}
  7.  
  8.  
  9. \begin{align}
  10. \ch{Ce + H_2 -> CeH_2}, \qquad \qquad \Delta &G_{rxn}^\circ=-115 kJ/mol \\[10pt]
  11. \ch{CeH_2 + 2.5Cl_2 -> CeCl_3 + 2HCl}, \qquad \qquad \Delta &G_{rxn}^\circ=-1007 kJ/mol\\[-40pt]
  12. \intertext{\centering or \vskip-20pt}
  13. \ch{CeH_2 + 1.5Cl_2 -> CeCl_3 + H_2}, \qquad \qquad \Delta &G_{rxn}^\circ=-812 kJ/mol
  14. \end{align}
  15.  
  16. \end{document}

parkerokabe
Posts: 7
Joined: Thu Apr 25, 2019 5:45 pm

Postby parkerokabe » Fri Apr 26, 2019 1:19 am

user22741 wrote:Your output looks just as it should. If you really want to reduce the space:

  1. \documentclass[review]{elsarticle}
  2.  
  3. \usepackage{lineno,hyperref,upgreek,graphicx,chemformula,subfig}
  4. \modulolinenumbers[5]
  5.  
  6. \begin{document}
  7.  
  8.  
  9. \begin{align}
  10. \ch{Ce + H_2 -> CeH_2}, \qquad \qquad \Delta &G_{rxn}^\circ=-115 kJ/mol \\[10pt]
  11. \ch{CeH_2 + 2.5Cl_2 -> CeCl_3 + 2HCl}, \qquad \qquad \Delta &G_{rxn}^\circ=-1007 kJ/mol\\[-40pt]
  12. \intertext{\centering or \vskip-20pt}
  13. \ch{CeH_2 + 1.5Cl_2 -> CeCl_3 + H_2}, \qquad \qquad \Delta &G_{rxn}^\circ=-812 kJ/mol
  14. \end{align}
  15.  
  16. \end{document}


Perfect! I didn't know you could put negative values in spacing. Thank you so much!

User avatar
Johannes_B
Site Moderator
Posts: 4004
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Fri Apr 26, 2019 6:39 am

You should try \shortintertext of package mathtools first.
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 “Math & Science”

Who is online

Users browsing this forum: No registered users and 0 guests