0

Can you define which lines and columns from a .txt file to show up in LaTeX? I tried the \lstinputlisting command where it seems I can only limit the output to specific lines and not columns as well, like in \lstinputlisting[firstline=1,lastline=1]{filename.txt} My aim is to only have to change the text in .txt file values in specific places so that I can easily keep my output updated. Is there a way to include columns in the \lstinputlisting command or is there another way to define specific text passages from .txt file?

  • 1
    I'm almost sure, there are other duplicates, e.g., for another verbatim package instead of listings. But as long a your question is absolutely unclear and as long a you don't show a MWE showing, why listings cannot be use, it IMHO does not make much sense to search for one, because I would suggest to use listings. – cabohah Mar 06 '24 at 14:05
  • The duplicate is not for \input. AFAIK there isn't any solution to input (and interpret) only some lines of a tex file. – cabohah Mar 06 '24 at 14:11
  • @cabohah Thanks, that helped. Still too new to comment on their thread, but maybe you know: Is it possible to add columns to this line? I couldn't make it work with listings.

    \lstinputlisting[firstline=,lastline=]{filename.txt}

    – Charles TeXavier Mar 06 '24 at 14:37
  • Columns in which respect? Sorry, your question is still unclear. So please ask a follow-up question with more information and minimal working example, or at least edit your question to add a minimal working example and explain your problem. BTW: firstline and lastline expect a value (e.g. firstline=5,lastline=10 see also the examples on the linked page and the listings user manual). – cabohah Mar 06 '24 at 14:43
  • A minimal working example would be nice, but even without it the question is reasonably clear in my opinion. Columns are the (character) positions in a line, for example the (currently non-existing) syntax firstline=1:5, lastline=2:10 would select a 'block' of 2x5 characters from the middle of line 1 and 2. Or maybe a simpler version where only the columns on a single line can be given, (also nonexisting) line=3:5:10 for characters 5-10 on line 3. – Marijn Mar 06 '24 at 21:12
  • @Marijn That's exactly what I meant, thanks. – Charles TeXavier Mar 07 '24 at 13:45

0 Answers0