[Tex/LaTex] importing select lines from external txt file

codeimportminted

is there a package that allows one to import a selection of lines from an external .txt file?

I know minted has a command that can be customized this way: \inputminted[firstline=3,lastline=5]{c}{hello.c} (see this link), but I'm looking for something more neutral, not specific to any programming language. This is because I'm writing a commands.txt file with a long list of Cisco's router/switch configuration commands that I'm learning, and I'd like to import only few required lines as a way to showcase examples. Obviously, minted doesn't include any 'cisco' language. I know of \verb and the verbatim environment, but I gather there could be problems with breaking long lines.

Best Answer

Instead of specifying a proper computer language for syntax highlighting in the environments of the minted package, you can use the option text. This will just typeset the input verbatim-like without syntax-highlighting but with the full functionality of the minted package.

In your case, you probably want to do use \inputminted with the firstline and lastline option. Additionally, just give text as first mandatory argument:

\documentclass{article}

\usepackage{minted}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.C}
int main() {
    printf("hello, world");
    return 0;
}
\end{filecontents*}

\begin{document}

\inputminted[firstline=2,lastline=3]{text}{\jobname.C}

\end{document}

enter image description here

Related Question