Skip to main content
34 votes

How to highlight (color/draw attention to) a particular snippet in Minted

You can highlight certain lines with highlightlines={1,2-3,5-10}, e.g. \begin{minted}[highlightlines={1,3-4,6-10}]{python} def f(x): y = x ** 2 return y def f(x): y = x ** 2 return y ...
ComFreek's user avatar
  • 1,278
24 votes

Best practices for source file line lengths?

I'll use an example from the TeXBook source This manual is intended for people who have never used \TeX\ before, as well as for experienced \TeX\ hackers. In other words, it's supposed to be a ...
David Carlisle's user avatar
17 votes

Can someone explain what is labxx in the source code of tex

The file you are looking at is not really "source code" it is tex0.c which is C derived (by web2c) from the tex.web source code of TeX, which is written in web (documented pascal). Almost ...
David Carlisle's user avatar
15 votes

Adding background color to \verb or \lstinline command without \Colorbox

You can patch \lstinline to use \Colorbox; of course you lose the possibility to break lines in \lstinline. \documentclass{article} \usepackage{xpatch} \usepackage{xcolor} \usepackage{listings} \...
egreg's user avatar
  • 1.1m
14 votes

Best practices for source file line lengths?

TeX engines can essentially deal with lines of any (reasonable) length so in that sense there is no forced limitation and starting new lines largely comes down to personal preferences and your ...
Frank Mittelbach's user avatar
13 votes

Best practices for source file line lengths?

The main problem is here that the error messages gives you the line number in which line the error was found. That means it could be in that line or the lines before. If you have long or very long ...
Mensch's user avatar
  • 65.6k
13 votes

Adding background color to \verb or \lstinline command without \Colorbox

(I rewrote this answer after the OP indicated that he/she was mainly interested in having all instances of \lstinline colored automatically, i.e., without having to encase the instances in explicit \...
Mico's user avatar
  • 514k
10 votes

Best practices for source file line lengths?

I'll break this down into two cases: 1. When defining macros, drawing tikz pictures and othwerwise writing mostly code: Short lines work well. Not necessarily one statement per line as is ...
Chris H's user avatar
  • 8,817
10 votes
Accepted

Moving arguments and \protect: coming to grips with the definitions

A 'moving' argument is where the argument to some LaTeX command will be 'moved around', either by writing it to a file, writing it to a message or by otherwise fully-expanding it. The confusion likely ...
Joseph Wright's user avatar
  • 262k
10 votes
Accepted

What does the \afterassignment do in the following macro from the TikZ source code?

It is similar to \futurelet in that it \let s the command name to the following token (ignoring one optional space) but unlike \futurelet it consumes the token \documentclass{article} \def\zza{\...
David Carlisle's user avatar
10 votes
Accepted

Reading LuaTeX source

The master luatex svn sources are currently not at a publicly accessible location, I understand that this is an essentially temporary situation due to a change of hosting arrangements however the ...
David Carlisle's user avatar
10 votes
Accepted

Where's the mandatory argument of sectioning commands?

Let's take the example of \section (all of them behave more or less the same, except for \chapter and \part). The definition is: \newcommand\section{\@startsection {section}{1}{\z@}% {-3....
Phelype Oleinik's user avatar
9 votes
Accepted

Listing source code in two columns

The example is generated by using the fancyvrb package. You can put the codes in two minipages and mimic a two column layout. Also note that the line numbers are somewhat misplaced; a solution is ...
Arash Esbati's user avatar
  • 7,481
9 votes
Accepted

Is it safe to define \@nil?

Most uses of \@nil just use \@nil as a macro argument delimiter so it doesn't matter what the definition is, however this is intentionally undefined. If you have code that is trying to execute \@nil ...
David Carlisle's user avatar
9 votes
Accepted

Is there a newmarks command?

If you're talking LaTeX, then \newmarks is there: > latexdef newmarks \newmarks: macro:->\e@alloc \marks \e@alloc@chardef {\count 256}\m@ne \e@alloc@top However \newmarks\thingy requires ...
egreg's user avatar
  • 1.1m
9 votes

what package should I use for $\mathscr{C}$?

To use \mathscr, you can use the mathrsfs package as already mentioned. I think it is also worth mentioning the mathalpha package, which allows to use several different math script fonts. Here's a ...
Vincent's user avatar
  • 20.3k
9 votes
Accepted

LaTeX code formatting regarding placement of floats and where best to place figures with respect to main body text references

This is probably no more than an expanded comment, but it does benefit from experience in juggling floats in TUGboat for (my idea of) best effect. Details of the rules of float placement are given in ...
barbara beeton's user avatar
8 votes
Accepted

How to embedded source code on-demand into PDF?

Yes, you may embed your source code as a file in the pdf. I'm using usually the package attachfile, but there are some more, the embedfile package e.g. or attachfile2. Using attachfile I'm printing ...
Keks Dose's user avatar
  • 31.3k
8 votes
Accepted

How to use true/false inside definitions?

The two constructs aren't equivalent. With \if@mybool \def\ps@myps{...T...}% \else \def\ps@myps{...F...}% \fi you test \if@mybool and define \ps@myps according to its truth value. Changing the ...
egreg's user avatar
  • 1.1m
8 votes

Two spaces in LaTeX code

No. Multiple consecutive spaces are gobbled into a single space within the code, unless they are hard coded (like using ~ or \ - a control space - or via \hspace, or ...). The setting of it might ...
Werner's user avatar
  • 607k
7 votes

Does the tab key do anything?

Let's look at latex.ltx, where we find 277 \catcode`\{=1 % left brace is begin-group character 278 \catcode`\}=2 % right brace is end-group character 279 \catcode`\$=3 % dollar sign is math shift 280 ...
egreg's user avatar
  • 1.1m
7 votes

How to upload my moduled tex files in arXiv?

It should work if you: add %auto-ignore to the first line of every text file but the main file compress your file tree prevents arXiv's system from compiling your non-main files independently ...
rafaelvalle's user avatar
7 votes

Source Code Indentation

Whether indenting "is possible" depends on the current category-code-régime and on the effects which you wish indenting to have. Under usual category-code-régime indenting by means of spaces ...
Ulrich Diez's user avatar
  • 29.7k
7 votes
Accepted

Where is \scope defined in the TikZ source code?

In the setup of TikZ environment \tikz@installcommands is invoked. % % Main TikZ Environment % \def\tikzpicture{% \begingroup% \tikz@startup@env% \pgfutil@ifnextchar[\tikz@picture{\tikz@...
percusse's user avatar
  • 158k
7 votes
Accepted

The meaning of two seemingly undefined control-sequences in the PGF source code

This is just the way TeX handles ifs. Further up you'll find \newif\ifpgfutil@in@ The statements \pgfutil@in@true \pgfutil@in@false have the effect to redefine \ifpgfutil@in@ to \iftrue and \...
Henri Menke's user avatar
7 votes
Accepted

LaTeX(2e) Programming vs. expl3 (which to learn)

Although I think that the question is quite broad, I try to answer it with the focus on package and class writing. I will use shortened versions of your questions: Is it worth to learn the stable ...
TeXnician's user avatar
  • 33.7k
7 votes
Accepted

Can one customize lstlisting environment?

The following code does the trick for the three keywords; as far as I can remember, the listings package makes no provision for coloring the numbers in the code. \documentclass[a4paper]{article} \...
GuM's user avatar
  • 21.7k
7 votes
Accepted

How to emphasize in a listing and keep source columns aligned?

You can hack into the commands for [i] type delimeters, \lst@BeginIDelim and \lst@EndIDelim. It would be nicer to add a new delimeter type, but this would require redefining a lot of internal commands....
Marcel Krüger's user avatar
7 votes
Accepted

Writing pseudocode for parallel programming

After some web research, I have realized that a kind of "standard" still does not exits. So here is my personal solution using algorithm2e: \usepackage[linesnumbered,ruled,vlined]{...
Leos313's user avatar
  • 659

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