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.

While searching for the source of missing line numbers, I realized that paragraphs followed immediately by an equation have no line number, but this is fixed when a space is included,

e.g. the following document has no line numbers:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lineno}
\linenumbers
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit: 
$$1+1=2$$ 
\end{document}

But this one does:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lineno}
\linenumbers
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit: 

$$1+1=2$$ 
\end{document}

The only difference is the space above the equation.

  • Why is this the case (and is there a simple workaround)?

  • Is it incorrect to include an indented equation in a paragraph, or is this just a 'feature' of lineno?

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

$$...$$ is obsolete, see Why is [ … ] preferable to $$. If you use the correct LaTeX displayed math environment, the numbering works without the empty line:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lineno}
\linenumbers
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit: 
\[1+1=2\] 
\end{document}

enter image description here

share|improve this answer
    
thank you, is $ also obsolete? –  David Aug 15 '11 at 21:04
    
@David: that's true, see: Are \( and \) preferable to $. At least: \( ... \) is LaTeX syntax, so better supported in LaTeX. $...$ is plain TeX. However, usually both work well, many prefer $...$ because it's easier to write or just classic. –  Stefan Kottwitz Aug 15 '11 at 21:09
2  
@David: \( and \) are fragile by default. So, as Will Robertson said, don't use them unless you use fixltx2e package. And the default \( and \) have very few advantages compared with $. –  Leo Liu Aug 16 '11 at 5:05
    
@StefanKottwitz, what could I do if I need numbered equations? –  Sigur Apr 3 '13 at 20:08
    
@Sigur Use an equation environment. –  Stefan Kottwitz Apr 3 '13 at 20:37
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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