# Tag Info

50

Alright, here's a go at numbering lines in a PDF (or any other image format) without access to the source. I wrote a little shell script that, using ImageMagick (at least version 6.6.9-4), converts a given PDF into separate raster images for each page, splits these into half pages, shrinks them to a width of one pixel (so takes the horizontal average, ...

47

This solution is very similar to that contained in How to make text copy in PDF previewers ignore lineno line numbers? \protecting the accsupp is the only requirement, perhaps due to the nature in which listings treats everything: \documentclass{article} \usepackage{xcolor}% http://ctan.org/pkg/xcolor \usepackage{listings}% http://ctan.org/pkg/listings ...

18

Have a look at the lineno package. I use it often like follows: % number the lines \usepackage{lineno,xcolor} % Running line numbers: \linenumbers \setlength\linenumbersep{5pt} \renewcommand\linenumberfont{\normalfont\tiny\sffamily\color{gray}} % Same, but that reset on every page: %\pagewiselinenumbers % Number only every 5:th line: %\modulolinenumbers[5] ...

18

Using a method similar to that proposed in How to make listings code correct copyable from PDF and with hyperlink, the following works (at least in Adobe Reader). The accsupp package provides accessibility support for PDFs. By using the \BeginAccSupp and \EndAccSupp group, the line numbers can be typeset in the PDF, but actually replaced by an empty space ...

17

According to the manual you can do this the following way: An optional argument to the \begin{algorithmic} statement can be used to turn on line numbering by giving a positive integer indicating the required frequency of line numbering. For example, \begin{algorithmic}[5] would cause every fifth line to be numbered. Obviously, \begin{algorithmic}[1] ...

13

(This is a copy of the comment I posted above. Now an answer due to Will Robertson's suggestion.) This addresses, partially, problem 2 described in the question. I've never seen problem 1 happen myself; then again, I haven't used lineno that much. Take a look at ulineno.pdf from http://www.ctan.org/tex-archive/macros/latex/contrib/lineno/ (the user's ...

13

The last annotation in the .aux file made by lineno is of the form \@LN{251}{5} where 251 is the global number of counted lines and 5 is the last page number. Of course this will depend on the document. If you say \AtEndDocument{\typeout{Total number of lines: \thelinenumber}} in your preamble, you'll see a message such as Total number of lines: 251 ...

10

You can easily treat your parameter file as a standard figure or a table; in the third example code below I used this approach. To add captions outside floating environments, you could use the \captionof command from the caption (or capt-of) package; in the last example code below I used this approach. To have automatic number line, monospaced font and ...

10

This answer only deals with latex/dvips/ps2pdf. Package accsupp works well with dvips. The generated PostScript file contains the right pdfmark operators. However ghostscript (version 9.05) has not implemented these tags, from the source file gdevpdfm.c: /* [ tag propdict /BDC pdfmark */ static int pdfmark_BDC(gx_device_pdf *pdev, gs_param_string *pairs, ...

10

Your MWE can be greatly reduced to be \documentclass{revtex4} \usepackage{lineno} \usepackage{blindtext} \pagewiselinenumbers \begin{document} \Blindtext \end{document} With such a simple MWE it becomes clear that the problem is an interaction between revtex4 and lineno. Searching the lineno documentation yields: if a class changes \output (APS ...

9

Why do you say that lineno cannot be used with memoir? I couldn't find any reference to this in the lineno documentation nor in the memoir manual. The only problem I see is that lineno doesn't number footnote text, but this is not for memoir, but also for the standard classes. To number footnote text too, you can use lineno and fnlineno (for numbering ...

9


9

This seems to work very well: \documentclass{article} \newlength{\linespagelength} \newcounter{linespage} \newcommand\linespage[2][0.4pt]{ \newpage \begingroup \baselineskip0pt \setlength{\linespagelength}{\textheight} \setcounter{linespage}{0} \loop \addtolength{\linespagelength}{-#2} \stepcounter{linespage} \ifdim\linespagelength>0pt ...

9

Page 2 of my copy of the manual mentions the modulo option: "Print line numbers only if they are multiples of five". \documentclass{article} \usepackage[modulo]{lineno} \linenumbers \usepackage{lipsum} \begin{document} \lipsum[1] \end{document}

9

You can do (1) easily with the pdfpages package. \documentclass{article} \usepackage{pdfpages} \begin{document} \includepdf[pages=1-,pagecommand={\thispagestyle{plain}}]{<pdffile>} \end{document} In the example document, I simply passed the pagestyle plain to the pagecommand, but using the fancyhdr package you can make any kind of extra ...

9

The following minimal example shows how to modify the starting line number for an algorithm. Within the algorithmic environment, add the code \makeatletter\setcounter{ALG@line}{<n>}\makeatother where <n> is one smaller than the first line number. The reason for this is because the \State command increments the counter first, before typesetting ...

9


7

You can use numberblanklines=false; a little example: \documentclass{article} \usepackage{listings} \lstset{numbers=left,numberblanklines=false} \begin{document} \begin{lstlisting} First line. Second line. \end{lstlisting} \end{document} The above approach will not number blank lines, but will take them into account for increasing the counter ...

7

Page 1, lines 11-12 of the lineno states: lineno.sty can only number lines in the main text. Lines in any kind of boxes cannot be numbered. But see section 7.4 below. The AMS class file typesets the abstract as part of the title page, but the abstract is specified using an environment. So it has to slurp in the text and save it for reuse. It does ...

7

Note that the error involving \@LN reports the macro to possibly take 2 arguments. This is confirmed from within lineno.sty: \def\@LN#1#2{{\expandafter\@@LN \csname LN@P#2C\@LN@column\expandafter\endcsname \csname LN@PO#2\endcsname {#1}{#2}}} So, just add \makeatletter \providecommand{\@LN}[2]{} ...

7

Inside the drama environment, the lnps and lnpa options for numbering have no effect. To get the numbering, you can use the lineno package, with \modulolinenumbers[5] to get numbering each five lines; you can activate the numbering invokink \linenumbers (or some other form of the numbering command offered by the package); you can also control the positioning ...

7

The general answer is: NEVER use any command related to typesetting text (\raggedright in your case) in the preamble. The specific answer in your case is: lineno.sty redefines the meaning of \\ (which you're using in your \newcommands) and issuing \raggedright before that redefinition causes the conflict. These are the lines in lineno.sty which cause ...

7

To just change the numbers, use the fontspec command \addfontfeatures{Numbers={Lining, Monospaced}} (see section 10.3 of the fontspec manual). (You probably don’t even need to specify Monospaced, but it doesn’t hurt to specify it.) \normalfont and \rmfamily aren’t necessary either. \documentclass{article} \usepackage{fontspec,lineno} ...

6

One option would be to use the more versatile algorithmicx package, with its algcompatible format (allowing you to use algorithmic syntax); you can use \STATEx for unnumbered lines: \documentclass{article} \usepackage{algcompatible} \begin{document} \begin{algorithmic}[1] \IF{some condition is true} \STATE do some processing \ELSIF{some other condition ...

Only top voted, non community-wiki answers of a minimum length are eligible