I'm trying to do the following: put the input line number (of the code) on each paragraph in the whole pdf output. For example, for the code
\documentclass{book}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\chapter{First chapter}
Text text text text text text text text text.
\section{First section}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{theorem}This is a theorem.
\end{theorem}
Text text text text text text text text text.
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\end{document}
The output must be
(Note: I did this example by doing \marginpar{\the\inputlineno} on every line on the source.)
For this purpose I am trying to use the \everypar command. Hence I tried the following
\documentclass{book}
\usepackage{amsthm}
\everypar={\marginpar{\the\inputlineno}}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\chapter{First chapter}
Text text text text text text text text text.
\section{First section}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{theorem}This is a theorem.
\end{theorem}
Text text text text text text text text text.
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\end{document}
But do nothing. Also, I tried to put it after \begin{document}, hence the number appears but only for the line \chapter. By applying the code used in this post Why does \everypar not work?. I obtained the following
\documentclass{book}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\let\oldep\everypar \newtoks\everypar\oldep{\the\everypar\the\inputlineno}
\chapter{First chapter}
Text text text text text text text text text.
\section{First section}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{theorem}This is a theorem.
\end{theorem}
Text text text text text text text text text.
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\end{document}
It's an start of what I want. I tried to put
\let\oldep\everypar \newtoks\everypar\oldep{\the\everypar\marginpar\the\inputlineno}
but send some errors:
! You can't use `\global' after \the.
\@minipagefalse ->\global
\let \if@minipage \iffalse
l.7 \chapter{First chapter}
I'm forgetting what you said and using zero instead.
Thanks in advance.



\marginpar? I put this code in the document I'm working on ( athesis.clsstyle document) and this move the headings to the left. – MrSelberg Aug 16 '15 at 12:59