Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

No matter what I do, I can't get the line to position properly. align* always wants to move it. and i can't use \noalignwithin \cee, or perhaps I'm not using it properly (beginner here)? Here's a MWE:

\documentclass{article} % [10] =10pt|11pt|12pt
\usepackage[fleqn]{amsmath} % standard math package 1/3
\usepackage[version=3]{mhchem} % insert chem equations
\usepackage[detect-none]{siunitx} % use proper si units
\usepackage{cancel} %strike out text

\begin{document}
  \begin{align*}
    \cee{
      \cancel{\mathrm{MgCl_{2(aq)}}} + \cancel{\mathrm{H_{2}O_{(l)}}} &-> MgO_{(s)} + \cancel{\mathrm{2HCl_{(aq)}}}
      &\Delta H_r&=\SI{105.037}{\kJ\per\mole} \\ 
      Mg_{(s)} + \cancel{\mathrm{2HCl_{(aq)}}} &-> \cancel{\mathrm{MgCl_{2(aq)}}} + \cancel{\mathrm{H_{2(g)}}}
      &\Delta H_r&=\SI{-447.667}{\kJ\per\mole}\\  
      \cancel{\mathrm{H_{2(g)}}} + 1/2O2_{(g)} &-> \cancel{\mathrm{H_{2}O_{(l)}}}
      &\Delta H_r&=\SI{-285.8}{\kJ\per\mole}  \\ 
      \rule{6cm}{1pt} \\
      Mg_{(s)} + 1/2O_{(g)} &-> MgO_{(s)}
    }
  \end{align*}
\end{document}
share|improve this question

marked as duplicate by cgnieder, Peter Jansson, Claudio Fiandrino, Svend Tveskæg, Jesse Mar 2 at 12:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 3 down vote accepted

Use an \intertext.

MWE:

\documentclass{article} % [10] =10pt|11pt|12pt
\usepackage[fleqn]{amsmath} % standard math package 1/3
\usepackage[version=3]{mhchem} % insert chem equations
\usepackage[detect-none]{siunitx} % use proper si units
\usepackage{cancel} %strike out text

\begin{document}
  \begin{align*}
    \cee{
      \cancel{\mathrm{MgCl_{2(aq)}}} + \cancel{\mathrm{H_{2}O_{(l)}}} &-> MgO_{(s)} + \cancel{\mathrm{2HCl_{(aq)}}}
      &\Delta H_r&=\SI{105.037}{\kJ\per\mole} \\
      Mg_{(s)} + \cancel{\mathrm{2HCl_{(aq)}}} &-> \cancel{\mathrm{MgCl_{2(aq)}}} + \cancel{\mathrm{H_{2(g)}}}
      &\Delta H_r&=\SI{-447.667}{\kJ\per\mole}\\
      \cancel{\mathrm{H_{2(g)}}} + 1/2O2_{(g)} &-> \cancel{\mathrm{H_{2}O_{(l)}}}
      &\Delta H_r&=\SI{-285.8}{\kJ\per\mole}}
    \intertext{\centerline{\rule{6cm}{1pt}}}
    \cee{
      Mg_{(s)} + 1/2O_{(g)} &-> MgO_{(s)}
    }
  \end{align*}
\end{document} 

Output:

enter image description here

Otherwise, if you don't want so much spacing, load mathtools (which loads amsmath) and use \shortintertext

MWE:

\documentclass{article} % [10] =10pt|11pt|12pt
\usepackage[fleqn]{mathtools} % standard math package 1/3
\usepackage[version=3]{mhchem} % insert chem equations
\usepackage[detect-none]{siunitx} % use proper si units
\usepackage{cancel} %strike out text

\begin{document}
  \begin{align*}
    \cee{
      \cancel{\mathrm{MgCl_{2(aq)}}} + \cancel{\mathrm{H_{2}O_{(l)}}} &-> MgO_{(s)} + \cancel{\mathrm{2HCl_{(aq)}}}
      &\Delta H_r&=\SI{105.037}{\kJ\per\mole} \\
      Mg_{(s)} + \cancel{\mathrm{2HCl_{(aq)}}} &-> \cancel{\mathrm{MgCl_{2(aq)}}} + \cancel{\mathrm{H_{2(g)}}}
      &\Delta H_r&=\SI{-447.667}{\kJ\per\mole}\\
      \cancel{\mathrm{H_{2(g)}}} + 1/2O2_{(g)} &-> \cancel{\mathrm{H_{2}O_{(l)}}}
      &\Delta H_r&=\SI{-285.8}{\kJ\per\mole}}
    \shortintertext{\centerline{\rule{6cm}{1pt}}}
    \cee{
      Mg_{(s)} + 1/2O_{(g)} &-> MgO_{(s)}
    }
  \end{align*}
\end{document} 

Output:

enter image description here

share|improve this answer
    
Actually I tried something very similar to this and it's fine except it makes a page break right after the line and the final chemical equation appears on the next page. (checking your recent edit now) –  Far Zin Mar 2 at 10:45
    
@FarZin This means that there is not enough room for the whole align* in the page. Force a manual break if you don't want this behavior. –  karlkoeller Mar 2 at 10:56

use

  \rlap{\rule{6cm}{1pt}} \\

then it has a width of 0pt

enter image description here

share|improve this answer
    
a width of 0pt? sorry when I replaced my \rule{6cm}{1pt} \\' with \rlap{\rule{6cm}{1pt}} \\' and printed it didn't work. seems like `align' is still moving it i –  Far Zin Mar 2 at 10:31
    
see my edited answer. Should the line be left or right aligned or centered? –  Herbert Mar 2 at 10:49

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