Hot answers tagged

34 votes

insert code keywords inline

This is also possible using the minted package and the highlighting tool pygmentize The command for minted inline code is called \mintinline{language}{code} The inline highlighting will only ...
Rico's user avatar
  • 6,057
27 votes

How to make a single word look as some code?

I can't believe nobody mentioned the listings package. It provides a command called \lstinline{your_code} which can even highlight keywords for you. See also this question: Should I use \lstinline ...
Domi W's user avatar
  • 370
27 votes

How can I type the symbol for usual topology $R_{(-)}$ in LaTex?

Sigur's answer might be appealing, but it has a big defect: with \usepackage{MnSymbol} you change every math symbol in your document to shapes that are thought to accompany Minion. Besides, I find ...
egreg's user avatar
  • 1.1m
25 votes
Accepted

What characters are allowed to use as delimiters for BibTeX keys?

First of all, spaces are not allowed in key names, so we can concentrate on other special characters. BibTeX I have prepared the following test file: @article{a{}b$, author={A. Uthor}, title={...
egreg's user avatar
  • 1.1m
21 votes

Using different colors for different keywords in lstlisting

This is a partial answer. I met this dirty trick once before: add otherkeywords={>,<,.,;,-,!,=,~} alongside morekeywords={>,<,.,;,-,!,=,~}. As for comma, there are other posts giving ...
Symbol 1's user avatar
  • 36.6k
18 votes

LaTeX code sniffer and/or beautifier?

I created a website that reformats the latex code to make indents consistent. This uses latexindent in the backend. This if a very rudimentary system but will do all simple indentation of items inside ...
Whitecat's user avatar
  • 1,281
18 votes
Accepted

Python-like dictionary in latex?

You can emulate it with a property list: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\DefineDictionary}{mm} { \arclupus_dict_def:nn { #1 } { #2 } } \seq_new:N ...
egreg's user avatar
  • 1.1m
18 votes

How to transcript codes from HP 50G in LaTeX

This answer tries to reproduce the screenshot. It uses the lcd package, which defines an extended alphanumeric character set, with each character constructed using dots set in a 5 x 7 matrix. Thus, ...
Ross's user avatar
  • 5,626
17 votes

Replicating a chronodex in TikZ

I recreated everything from scratch and made it a \pic that is highly customizable and allows for 24-hours or am/pm format. It uses the calendar library which should make it easy to create a full ...
Jasper Habicht's user avatar
15 votes

Insert Bash code with coloration into my latex report

listings does not work well for shell code because it can not deal well with a lot of codes such as the following one: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \lstset{...
Bruno BEAUFILS's user avatar
15 votes

How to format an inline source code

You can create your \inlinecode command which adapts to various languages. Here is some piece of code I've been using and which was very helpful to me: \usepackage{listings} \usepackage{color} \...
Salvioner's user avatar
  • 483
15 votes
Accepted

Display bash code in LaTeX

In LaTeX, in order to display bash code and any other code, you can use the listings package. The \lstset command is used to control the basic appearance, including the language of code. Please see ...
Masroor's user avatar
  • 17.7k
15 votes

How can I type the symbol for usual topology $R_{(-)}$ in LaTex?

Another possibility, cutting out the parenthesis from a \bigcirc to get more round symbols. To get a more similar symbols with square brackets, I cut them out of amssymb's \square. \documentclass{...
Vincent's user avatar
  • 19.4k
14 votes
Accepted

Is it possible to use tikzmark inside minted?

Yes, it appears to work, you just need to specify an escape character (? here) to minted so you can insert the \tikzmark. \documentclass{article} \usepackage{minted} \usepackage{tikz} \usetikzlibrary{...
David Carlisle's user avatar
14 votes

Triangle Notation in Spain

You can import the symbol from yhmath: \documentclass{article} \usepackage{amsmath} \DeclareSymbolFont{yhlargesymbols}{OMX}{yhex}{m}{n} \DeclareMathAccent{\widetriangle}{\mathord}{yhlargesymbols}{"...
egreg's user avatar
  • 1.1m
13 votes
Accepted

Censor minted source code in pdf

It is hard to have the minted environment itself as an argument to \censorbox, because it contains verbatim material. At the time where it is passed as an argument, the catcodes are fixed and the ...
Henri Menke's user avatar
13 votes

How to illustrate the Mean Value theorem?

Some PSTricks solutions only for fun purposes! \documentclass[pstricks,border=12pt,12pt]{standalone} \usepackage{pst-plot,pst-eucl} \def\f{(x-1)^2/5+1} \def\L#1#2#3{\psCoordinates[linestyle=dashed](#...
Second Person Shooter's user avatar
13 votes
Accepted

Single-key teletype?

\documentclass{article} \usepackage{shortvrb} \MakeShortVerb| \begin{document} this |and| that or |the other| \end{document} shortvrb is in the core base latex distribution.
David Carlisle's user avatar
12 votes
Accepted

How to transcript codes from HP 50G in LaTeX

Does this look better? \documentclass[a4paper]{article} \usepackage{listings} \lstset{basicstyle=\ttfamily, columns=fullflexible, keepspaces=true} \begin{document} \begin{lstlisting} << SWAP ...
Thruston's user avatar
  • 41.7k
12 votes

How to present a Python code snippet efficiently in LaTeX?

Here is the way I like to do. Of course you can change colors, font sizes, borders and so on. You need Pygments to use minted. MWE \documentclass[11pt,a4paper]{report} \usepackage{tcolorbox} \...
Sigur's user avatar
  • 36.9k
12 votes

How can I type the symbol for usual topology $R_{(-)}$ in LaTex?

Just because a tikz answer is always required ... Here is one using the Arc Barb arrowhead style of the arrows.meta library. EDIT Added a line cap=round option to show that you can pretty much ...
BambOo's user avatar
  • 8,739
11 votes

Aligning table within latex editor

In TexStudio you select the data in your table and go to (top of the screen) LaTeX > Manipulate Tables > Align Columns This will neatly align your table at the &'s.
Gilian's user avatar
  • 111
11 votes

Triangle Notation in Spain

\documentclass{article} \usepackage{stackengine,scalerel,graphicx} \stackMath \newcommand\that[1]{% \setbox0=\hbox{$#1$}% \ensurestackMath{% \stackon[2pt]{\copy0}{\,\rotatebox{90}{\stretchto{\...
Steven B. Segletes's user avatar
11 votes

Single-key teletype?

Use fancyvrb and \DefineShortVerb (although you might not want to use `) \documentclass{article} \usepackage{fancyvrb} \DefineShortVerb\` \begin{document} I'm writing a document with a ton of ...
Phelype Oleinik's user avatar
11 votes
Accepted

How can I type the symbol for usual topology $R_{(-)}$ in LaTex?

What about \leftfree \mkern -12mu \rightfree from MnSymbol package? \documentclass{report} \usepackage{amssymb} \usepackage{MnSymbol} \begin{document} \[ \mathbb{R}_{\leftfree\mkern -12mu\rightfree} \...
Sigur's user avatar
  • 36.9k
10 votes

How can I auto-indent in TeXstudio?

There is also Indent and unindent automatically under Options -> Editor -> Indentation Mode. I understand the author is happy with previous suggestions, but I hope it may help others since this ...
Alex's user avatar
  • 231
10 votes
Accepted

How to call out sections of source code?

Based on cmhughes comment sugessting the use of tikzmark, and the multiline bracket solution found here, I was able to come up with the following: \documentclass{article} \usepackage{enumitem} \...
hudsonb's user avatar
  • 323

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