17 Comments

  1. Sounds like a nice package. I’d love to use it. Unfortunately, my paragraphs containing align environments don’t get counted or numbered, that is neither the equations nor the text surrounding it.

    Any idea how to fix this?

    Best wishes,
    Almut

    • Hi Almut!

      Fixing the text surrounding is easy, just add an empty line before the align environment or some of the solutions provided here.

      Adding line numbers to the equations is more tricky. I tried a fix posted by Ted some time ago. When I encapsulate align with linenomath:

      \begin{linenomath*}
      	\begin{eqnarray}
      		...
      
      	\end{eqnarray}
      \end{linenomath*}

      I get a funny double number on the last equation. He also mentioned double numbers, but only in his first fix.

      Does anyone know how to fix this?

      Thanks, Tom.

      • Thanks for the reply Tom!

        However, the line numbers aren’t necessary and would be just for my convenience while writing my thesis, so any changes in the text are overkill in my case. I’ll survive without them. 🙂

        Best wishes,
        Almut

      • tedpavlic

        The double-line numbers are an artificate of TeX not setting text on a grid. Occassionally (but not always), you’re going to get an extra number between an equation and the surrounding text, especially if your equation is “tall.” Given the substrate on which TeX documents are constructed, preventing these problems is a significant challenge.

  2. Robert Paynter

    Are there any other methods? I think what I’m after is a page decoration rather than text markup as {lineno} package does – it puts numbers for each line of text. I would like numbering down the edge of the page so that someone can refer to a place on the page irrespective of whether it is a line of text, an equation or a figure (with labels).

    • tom

      Hi Robert,

      Below is some code which I adapted slightly from its source. It prints line numbers irrespective of the content. Obviously, these line numbers might not perfectly coincide with the actual content. A shift happens whenever the height of an object (such as a figure) is not a multiple of the ‘line height’.

      I hope this is what you were looking for.

      Best, Tom

      \documentclass[10pt]{article}
      \usepackage{fancyhdr,blindtext,amsmath}
      
      \makeatletter
       \newsavebox{\@linebox}
       \savebox{\@linebox}[3em][t]{\parbox[t]{3em}{%
         \@tempcnta\@ne\relax
         \loop{\scriptsize\the\@tempcnta}\\
           \advance\@tempcnta by \@ne\ifnum\@tempcnta<48\repeat}}
       \pagestyle{fancy}
       \fancyhead{}
       \fancyfoot{}
       \fancyhead[LE]{\footnotesize\thepage\begin{picture}(0,0)%
            \put(-26,-25){\usebox{\@linebox}}%
            \end{picture}}
       \fancyhead[LO]{%
          \begin{picture}(0,0)%
            \put(-18,-25){\usebox{\@linebox}}%
           \end{picture}}
      \makeatother
      
      \begin{document}
      \section*{Lorem Ipsum}
      \begin{figure}[ht]
      \begin{center}
      \rule{2cm}{2cm}
      \caption{default}
      \label{default}
      \end{center}
      \end{figure}
      \Blindtext
      \begin{align}y=a\cdot{}x+b\end{align}
      \end{document}
    • tom

      Hi there,

      That’s an interesting question. Use the following code to show line numbers on both sides of the text. I took the solution from here.

      HTH, Tom

      \documentclass{article}
      \usepackage{blindtext}
      \usepackage{lineno}
      \makeatletter
      \def\makeLineNumberLeft{%
        \linenumberfont\llap{\hb@xt@\linenumberwidth{\LineNumber\hss}\hskip\linenumbersep}% left line number
        \hskip\columnwidth% skip over column of text
        \rlap{\hskip\linenumbersep\hb@xt@\linenumberwidth{\hss\LineNumber}}\hss}% right line number
      \leftlinenumbers% Re-issue [left] option
      \makeatother
      \linenumbers
      \begin{document}
      \blindtext
      \end{document}

Leave a Reply