4

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

  • 2
    This solution works on the PDF itself. Add page and line numbers to a pdf – Alan Munn Jul 19 '19 at 14:44
  • Please try with vruler.sty package... – MadyYuvi Jul 19 '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 https://tex.stackexchange.com/questions/18760/add-page-and-line-numbers-to-a-pdf does not work. – Student Jul 19 '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 '19 at 17:21
  • @AlanMunn Thank you very much. Please just how can I add ImageMagick? – Student Jul 19 '19 at 17:25
  • @Student https://imagemagick.org/index.php But if you're using Windows, the script in the answer (not ImageMagick itself) won't work. If you're using Mac or Linux it should work. – Alan Munn Jul 19 '19 at 17:30
  • I'm using windows. The template does not work. I don't kow what should I do. I will be greatfull if you can help me. – Student Jul 19 '19 at 17:32
  • Should I download the software from this link:https://imagemagick.org/script/download.php? – Student Jul 19 '19 at 17:37
  • @Student Yes, you can download it from there. But I know nothing about Windows. And learning how to translate a bash script into a Windows .bat file is not a TeX question, and so off topic for the site. – Alan Munn Jul 19 '19 at 17:38

1 Answers1

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.

Werner
  • 603,163