1

I've had several persistent issues with the lineno package and journal article templates (e.g., not numbering certain paragraphs). Is it possible to just add an "unaligned" column of line numbers on the side of the page?

enter image description here

  • 1
    This solution works on the PDF itself. Add page and line numbers to a pdf – Alan Munn Jul 19 at 14:44
  • Please try with vruler.sty package... – MadyYuvi Jul 19 at 14:58
  • @AlanMunn Please if I have a PdF file. Is it possible to add numbers to all the lines? Unfortunaletly, this template in this answer tex.stackexchange.com/questions/18760/… does not work. – Student Jul 19 at 17:17
  • @Student "does not work" is a very vague description, and this question is not the place to have a discussion about it. The solution has quite a few components, including a shell script that calls ImageMagick which you need to run on the file before using the LaTeX code. If you've done all that, ask a new question showing exactly what you did and linking to the original question. – Alan Munn Jul 19 at 17:21
  • @AlanMunn Thank you very much. Please just how can I add ImageMagick ? – Student Jul 19 at 17:25
2

The following example uses eso-pic to place a list of numbers (contained within a single-column tabular) on the left and/or right of the text block:

enter image description here

\documentclass{article}

\usepackage{lipsum,eso-pic,xcolor}

% Specify a verbatim list of numbers (or items) to be on the side of the text block
\newcommand{\numberlist}[1][r]{%
  \begin{tabular}{#1}
    \strut
     1 \\  2 \\  3 \\  4 \\  5 \\  6 \\  7 \\  8 \\  9 \\ 10 \\
    11 \\ 12 \\ 13 \\ 14 \\ 15 \\ 16 \\ 17 \\ 18 \\ 19 \\ 20 \\
    21 \\ 22 \\ 23 \\ 24 \\ 25 \\ 26 \\ 27 \\ 28 \\ 29 \\ 20 \\
    31 \\ 32 \\ 33 \\ 34 \\ 35 \\ 36 \\ 37 \\ 38 \\ 39 \\ 30 \\
    41 \\ 42 \\ 43 \\ 44 \\ 45 \\ 46
  \end{tabular}%
}

\newcommand{\numberlistfont}{%
  \ttfamily\color{black!50}% Font/colour used for number list
}

% Add number list to the ForeGround of every page
\AddToShipoutPictureFG{%
  % Start at the top left of the text block
  \AtTextUpperLeft{%
    \numberlistfont
    % Numbers on left
    \makebox[0pt][r]{\raisebox{-\height}{%
      \numberlist[r]% Print numbers, right-aligned
    }%
    \hspace{50pt}% Space between left numbers and text block
    }%
    \hspace*{\textwidth}% Just to right side of text block
    \hspace{3em}% Space between right numbers and text block
    \makebox[0pt][l]{\raisebox{-\height}{%
      \numberlist[l]% Print numbers, left-aligned
    }}%
  }%
}

\begin{document}

\sloppy\lipsum[1-50]\lipsum[1-50]

\end{document}

You can adjust the lengths and definitions based on the commented code.

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.