1

just like How can I superimpose LaTeX / TeX output over a PDF file? except I want to write over a multi-page text file, brought into my main .tex file with:

 \newgeometry{left=3mm,right=5mm}
 VerbatimInput{} 
 \restoregeometry

from Include data from a .txt verbatim . Additionally, due to the text file, I also wrapped a margin changer.

If I can write on top of this text with absolute positioning I can't image the margins being a problem.

Other than writing on top of pdfs, or forcing figures on top of each other, I did not see anything useful (at least that I could understand).

Lastly, I would like to write in a different color, but I guess I could just do something like

 {\color{blue}{text here}}

I didn't provide a MWE because my data file I would like to write upon is long but not really important, and the two links I provided should suffice... I hope!

P.S. I should note that I can get things like this: How can I set the position of text along path in tikz more precisely? to work - text on a tikz path, but I'm unsure how to do such things, positioned absolutely, for a specific page in a multi-page text file from VerbatimInput. Also, I don't need a path, just normal text...

P.P.S. I guess what an equivalent thing I would like is something like this.

 \begin{verbatim}
 copy and pasted text from data file
 \end{verbatim}
 ...at this line, the reason for the above text in the text file is...
 \begin{verbatim}
 continuing copy and paste of data file
 \end{verbatim}
 ...another comment about something in the data file, probably in color
 \begin{verbatim}
 rest of copy and paste of data file
 \end{verbatim}

The only problem, which is minor, is that it makes my .tex file long and hard to naviage.

nate
  • 835
  • 1
    If you use listings package, you can define which lines are included in your text, so you can include comments as regular text between fragments of verbatim code. – Ignasi Dec 09 '15 at 16:29
  • Thanks! Works perfectly, by doing this: \lstinputlisting[firstline=1,lastline=5]{file} comment \lstinputlisting[firstline=6,lastline=8]{file} If you make it an answer I'll accept it. comment – nate Dec 09 '15 at 19:10

1 Answers1

1

firstline and lastline options for listing (or lstinputlisting) commands from listings package can be used to display a specific fragment from a listing (code, verbatim, ...). With them there's no need to insert regular comments inside a code listing because you can do the other way round: insert code fragments inside a regular document.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{listings}

\lstset{
    language=[LaTeX]TeX,
    basicstyle=\ttfamily,
    frame=single
    }

\begin{document}
Preamble follows
\lstinputlisting[firstline=1,lastline=11]{282168.tex}

Document body is shown in next box
\lstinputlisting[firstline=14,lastline=20]{282168.tex}
\end{document}

enter image description here

Ignasi
  • 136,588