Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

# Tag Info

1

Here is a simple solution using the filecontentsdef package. We define a new environment collectverb which first reads the environment body into a macro \collectverb@tl using \filecontentsdefmacro. The contents is then written to the output file \collectverb@out and after that printed in the document. For the typesetting of the code internal macros of the ...

1

Not an answer to the question, but rather an answer to your comment asking for a workaround: Okay, I will ask on the mailing list. But still is there any way at this moment to avoid the renumbering? Not recommending to use this even as a workaround but perhaps something similar? \defineframedtext [framedcode] [strut=yes, offset=2mm, width=7cm,...

6

\documentclass{article} \usepackage[most]{tcolorbox} \begin{document} \begin{tcblisting}{sidebyside,title=Test} % Example of LaTeX code This is \textbf{not} a test. This is not a test. This is not a test. This is not a test. $x+2=0$ $x=-2$ \dotfill $x$ is negative \end{tcblisting} \end{document} In case that the right side should be different in ...

4

I suggest fancyvrb and its BVerbatim enviroment. \documentclass{article} \usepackage{fancyvrb,booktabs} \newenvironment{tabularverbatim} {\VerbatimEnvironment \begin{BVerbatim}[baseline=c,formatcom=\setlength{\baselineskip}{\normalbaselineskip}]} {\end{BVerbatim}} \begin{document} \begin{tabular}{cccc} \toprule SID & the number of elements & ...

1

Assume you have the entire code block inside a box. Let's call this box \verbbox. The easiest way to have a tight box around the code would be to use varwidth: \usepackage{varwidth} \newsavebox{\verbbox} \begin{lrbox}{\verbbox} \begin{varwidth}{\linewidth} \begin{verbatim} <c> <d> <a> <{cd}> <ca> <da> <cd> <dd&...

1

Here is a version with vertically centered contents: \documentclass{article} \usepackage{listings} % For thelstlisting environment \usepackage{makecell} % For manual linebreaks in table headers \renewcommand{\theadfont}{\normalsize} \usepackage{booktabs} % For horizontal lines with better spacing \begin{document} {\lstset{aboveskip=0pt,belowskip=0pt} \...

0

Please make the value of \topsep should be 0 will help you to fix it, and the modified code is: \documentclass{book} \begin{document} \setlength{\topsep}{0pt} \begin{tabular}{cccp{3cm}} \hline SID & the number of elements & length & the number of its non-empty\\ \hline 1 & 2 & 4 & \begin{...

3

A simple method is with fancyvrb and fvextra: \documentclass{article} \usepackage{fancyvrb,fvextra} \usepackage{showframe} % just for the example \begin{document} \begin{Verbatim}[breaklines] curl -v -s -X POST \$OS_AUTH_URL/auth/tokens?nocatalog -H "Content-Type: application/json" -d '{ "auth": { "identity": { "methods": ["password"],"password": {"user": ...

3

Here is an option with fancyvrb where you can change the formatting of specific lines; the code should be self-explanatory: \documentclass{article} \usepackage{fancyvrb,xcolor} \begin{document} Write this: \begin{Verbatim} function doit() { console.log("Hello"); } \end{Verbatim} And then add these lines: \renewcommand{\FancyVerbFormatLine}[1]{% \...

2

Took this: How can I highlight some lines from source code? Made this: \documentclass{article} \usepackage{soul,listings,xcolor} \lstnewenvironment{teX}[1][] {\lstset{language=[LaTeX]TeX}\lstset{escapeinside={(*@}{@*)}, numbers=left,numberstyle=\normalsize,stepnumber=1,numbersep=5pt, breaklines=true, %firstnumber=last, ...

Top 50 recent answers are included