New answers tagged

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 ...


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{...


3

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


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.


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 ...


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 ...


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 ...


4

You can use \texttt{++} instead, can't you? \documentclass{article} \usepackage{tcolorbox} \definecolor{mycolor}{rgb}{0.122, 0.435, 0.698} \newtcbox{\mybox}{nobeforeafter,colframe=mycolor,colback=mycolor!10!white,boxrule=0.5pt,arc=4pt, boxsep=-3pt,left=6pt,right=6pt,top=6pt,bottom=6pt,tcbox raise base} \begin{document} \mybox{C\texttt{++}} \end{...


4

I hope, at least this compiles for the O.P. ;-) \tcboxverb is designed for such small boxes with verbatim content. I've added a myboxstyle TikZ style for this. \documentclass{article} \usepackage[most]{tcolorbox} \definecolor{mycolor}{rgb}{0.122, 0.435, 0.698} %\newtcbox{\mybox}{nobeforeafter,colframe=mycolor,colback=mycolor!10!white,boxrule=0.5pt,arc=...



Top 50 recent answers are included