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 ...
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 ...
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 ...
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={...
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 ...
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 ...
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 ...
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, ...
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 ...
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{...
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}
\...
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 ...
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{...
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{...
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}{"...
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 ...
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](#...
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.
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 ...
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}
\...
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 ...
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.
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{\...
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 ...
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} \...
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 ...
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}
\...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
code × 736listings × 229
minted × 77
verbatim × 48
formatting × 46
color × 36
tables × 29
highlighting × 28
sourcecode × 26
python × 24
fonts × 22
macros × 21
beamer × 18
tikz-pgf × 17
pdftex × 16
packages × 16
line-breaking × 16
environments × 14
matlab × 14
lyx × 13
tcolorbox × 13
math-mode × 12
spacing × 12
indentation × 12
overleaf × 12