1

I am using \centerline to center text, and I need to count the line numbers. I use the lineno package, but I found that the content contained in \centerline will not be included in the line number. Because I need to process latex files that have been written in batches, I want to know the reason for this situation and whether there is a way to solve it by \renewcommand.

\documentclass{article}
\usepackage{lineno}
\usepackage{listings}
\linenumbers

\begin{document}

\centerline{This is also ok!}

\centerline{But not}

test
\\test
\\test
\\test

\end{document}

enter image description here

1 Answer 1

1

\centerline shouldn't really be used in latex it's a remnant of plain TeX and doesn't follow any of the normal conventions of a latex box.

As you are using it already the simplest fix is to use \noindent\centerline{..} then it will be seen by the line numbering.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .