Hot answers tagged

7

\documentclass[a4paper]{scrbook} \usepackage{fancyvrb} \usepackage[utf8]{inputenc} \usepackage{pmboxdraw} \pmboxdrawsetup{ Block/box={\texttt{0}}, } \begin{document} \begin{verbatim} NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 32G 0 disk ├─sda1 8:1 0 99M 0 part /boot └─sda2 8:2 0 31,9G 0 part / sr0 11:0 1 55,5M 0 ...


5

The syntax colored listings are solved by OPmac tricks 0124 (C syntax), 126 (html syntax) or 0152 (Python syntax). You can simply extend these macros for another language, if you need. Note that referred macros need not any special external processor. All is done in classical TeX.


5

The simplest method I can think of is to just use listings's escapechar key. This requires choosing a character that doesn't appear in the code. For example, I've used the pipe character | below, but this would need to be changed to something else if the code fragment contained, say, a logical or bitwise or operation. \documentclass{article} \usepackage{...


4

The comment environment is defined by the verbatim package as a variant of verbatim: instead of printing each line, it simply throws it away. The package defines its verbatim-like environments by doing some steps. First all special characters (well, almost all) become non special; then TeX is instructed to absorb one line at a time, checking whether it ...


4

The following employs moredelim and some boxing to have any (syntax-formatted) part of a listing as hyperlink: int main(){ @foo@(); // <-- identifier is hyperlink } The link target (URL) is specified with the macro \btSetUrl{ theurl }. You could setup it once or redefine it inside the listing using any of listings's escape-to-latex options. In the ...


3

It works for me (texlive 2016) with pdflatex or with lualatex if I add \RequirePackage{luatex85} as first line


3

You can try with the capabilities of listings: \documentclass{article} \usepackage{listings,todonotes} \lstnewenvironment{todoverbatim}[1][] {\lstset{ basicstyle=\ttfamily, columns=flexible, escapeinside = {/*}{*/} }} {} \begin{document} \begin{verbatim} dset ^newcase_d01_2612.dat options byteswapped undef 1.e30 title OUTPUT ...


2

The manual doesn't say that a font selection is done when delivering the argument after it has grabbed “in a way similar to \verb” just because it doesn't happen in the first place. So \NewDocumentCommand{\myVerbatim}{v}{\texttt{#1}} will emulate \verb (but \verb does some more things).


2

Knuth has developed the list.tex macros to produce code listings. To produce a listing of the file test.c with the content #include <stdio.h> int main() { printf("Hello World!\n"); } we input on the terminal $ pdftex list.tex test.c <<< "\\bye" and obtain the following output Drawbacks: No syntax highlighting Overly long lines ...



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