New answers tagged

2

Referencing the question pointed out by @Kurt (I recommend to read the answers posted): How to change the name of document elements like "Figure", "Contents", "Bibliography", "Appendix", etc.? , the answer is that minted uses other macro names that the ones I was using, concretely, an answer (by @hpesoj626) gives this ...


1

You can use literate to replace the char with a suitable command: \documentclass[titlepage, a4paper]{mwart} \usepackage{amsmath,amsfonts,amssymb,amsthm} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{polski} \usepackage{graphicx} \usepackage{listings} \usepackage{xcolor} \lstdefinestyle{sharpc}{language=[Sharp]C, frame=lr, ...


1

From Section 2.5 of documentation simply use \begin{lstlisting}[extendedchars=false] ą \end{lstlisting}


0

I like the simplicity of this answer. 1) before \begin{document} put: \usepackage{color} 2) In your listings use colorbox like this: \begin{lstlisting}[escapechar=!] ...not highlighted... !\colorbox{yellow}{...**HIGHLIGHTED**...}! ...not highlighted... \end{lstlisting}


0

I like the simplicity of this answer. 1) before \begin{document} put: \usepackage{color} 2) In your listings use colorbox like this: \begin{lstlisting}[escapechar=!] ...not highlighted... !\colorbox{yellow}{...**HIGHLIGHTED**...}! ...not highlighted... \end{lstlisting}


0

using xparse package you can easyly define your own environments (it works like some kind of macros), they provide a good manual to how this can be done. xparse ctan


1

Short answer: you can't pass a lstlisting environment as the argument to a macro. You can define a new environment, instead. \documentclass[a4paper,11pt, onecolumn, openany,]{memoir} \usepackage[english]{babel} % English please %\usepackage[final]{microtype} % Less badboxes \usepackage{fontspec} \usepackage{listings} \usepackage{xcolor} ...


3

The source of the missing List of... is, that the acl2013 package does use following lines % We're never going to need a table of contents, so just flush it to % save space --- suggested by drstrip@sandia-2 \def\addcontentsline#1#2#3{} i.e. \addcontentsline does nothing and there's no change to write a .lof or .lol etc. This effective code is annoying, ...


2

you have to run the document twice. However, use package caption and \captionof if you do not want the image to float around. \listfiles \documentclass{article} \usepackage[T1]{fontenc} \usepackage[demo]{graphicx} \usepackage{listings} \usepackage{caption} \begin{document} \begin{lstlisting}[caption={Testcode is here}\label{lst:Testcode is ...


0

Being in the same situation and having many code listings, I didn't want to make a separate tex file for each listing. I found that by declaring the minted environment as a "standalone environment", on line 4 below, you can have multiple listings that get separate pages in the produced pdf: \documentclass[varwidth=6cm, border={0.5cm 0.1cm 0.1cm ...


1

You can't put a lstlisting environment directly in an lrbox, but you can in a \vbox (a lower level object). \documentclass{beamer} \usepackage{listings} \lstnewenvironment{code}[2][] {\lstset{#1}\global\setbox#2\vbox\bgroup} {\egroup} \newsavebox{\mybox} \begin{document} \begin{code}[basicstyle=\ttfamily]{\mybox} blahblahblah \end{code} \begin{frame} ...


2

Package listingsutf8 re-encodes the listing file from UTF-8 to the specified 8-bit encoding before passing it to listings. Since the encoding actually changes, package \inputencoding loads the new definitions for the active characters of the encoding from the .def file (latin1.def). These re-definitions has to be repeated each time the encoding is changed. ...


1

Listings(utf8) uses the standard interface \inputencoding{XXX} from the inputenc package to change the various encoding related definitions. \inputencoding loads the definitions from the XXX.def-file. While it is certainly possible to store the definitions in a macro instead of reloading them from the .def I don't think that inputenc should do it by default. ...


3

Use the minted package. It does syntax highlighting with the pygments Python library, which happens to support Julia. It's not mentioned on the main language list, but there's a Julia code sample right here. Edit: Also, Julia interactive output is supported through the jlcon lexer.


3

You can insert tokens with escapebegin and escapeend. If you don't use mathescape but escapechar you can e.g. switch to displaystyle: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{listings} % #################################################################### COLORS # \lstset{language=, keepspaces=true, ...


2

Interesting question! \documentclass{article} \usepackage{listings} \lstset{language=, keepspaces=true, basicstyle=\ttfamily, columns=fullflexible, mathescape=true, } \newcommand{\PRESPACE}{\vadjust pre{\vskip\abovedisplayskip}} \newcommand{\POSTSPACE}{\vadjust{\vskip\belowdisplayskip}} \newcommand{\DS}{% ...


3

We can use lst@outputspace for configuring inter-word space, but id doesn't suffice to set it to normal space, we must also configure CSS for listing environment to break lines. Try this config file: \Preamble{xhtml} \begin{document} \makeatletter \def\lst@outputspace{\HCode{ }} \makeatother \Css{div.lstlisting{white-space:pre-wrap;}} \EndPreamble ...


5

This should do what you want. \newenvironment{sourcecode}[1] {% \VerbatimEnvironment \def\savedcaption{\caption{#1}}% \begin{listing}[ht]% \begin{python3code}% } {% \end{python3code}% \savedcaption \end{listing}% } You need \VerbatimEnvironment, because you are creating an environment that uses fancyvrb internally. You need a ...


2

Run with xelatex or lualatex: \documentclass{article} \usepackage{fontspec} \setmonofont{DejaVu Sans Mono} \usepackage{fancyvrb} \begin{document} \begin{Verbatim}[fontsize=\small] 1---2----3--------| ---s---------s---| ↓ ↓ ---1*--------3***| \end{Verbatim} \bigskip \begin{Verbatim}[fontsize=\small] ----s---------s---| ↓ ...


4

listings is a viable option, but there are some minor alignment issues. Here are two alternatives using fancyvrb and a regular verbatim environment: \documentclass{article} \usepackage{listings,fancyvrb} \newcommand{\da}{% down arrow \phantom{x}% \makebox[0pt][r]{$\downarrow$}} \begin{document} ...


6

The characters in most fonts do not have the same width, i.e. a 't' might be narrower than the letter a, the character width of the fonts are proportional then. If all characters should have the same width, use a non-proportional font, such as typewriter font (e.g. Courier), which is enabled, for example with \ttfamily. In addition I suggest to use the ...


4

Just add the font size to your basicstyle, e.g., basicstyle = \ttfamily\small, Of course, with that dramatic indentation, you need much smaller fonts: If you do \begin{lstlisting}[style=json,basicstyle=\ttfamily\tiny] [{"stops": [{ "arrival_time": { "mon-fri": [ "04:31", "04:43"], ...


0

Pretty simple solution. Problem was that I set beamercovered to transparent. It seems LaTeX doesn't like that for listings/blocks. Just remove \setbeamercovered{transparent} or set it to invisible before the listings. ... \setbeamercovered{invisible} % frame with blocks and listings etc. ... \setbeamercovered{transparent} ... This makes overlayed ...


6

If you delete this line keywords = {false,true}, the string "true" is treated as a string and goes red


2

You should load minted before classicthesis, otherwise you get a pdfTeX warning (ext4): destination with the same identifier (name{figure.0.1}) has been already used, duplicate ignored warning, with incorrect hyperlinks. Then you can make \l@listing the same as \l@figure, which is what newfloat does anyway, but after classicthesis has modified the ...


1

minted loads the newfloat-Package if the identical option is applied. newfloat uses the \listoffigure command for new lists. Looks like this is a bit buggy - but I'm not sure who to blame: me, newfloat, minted or classicthesis. In order to fix the list of listings I had to overwrite the \cftfigpresnum command. ...


4

If you use the "containsverbatim" option instead of "fragile" your minimal example works: \begin{frame}[containsverbatim]{test} \begin{lstlisting} \begin{frame} \titlepage \end{frame} \end{lstlisting} \end{frame} I found the solution in this post: http://stackoverflow.com/questions/2981008/latex-issue-with-beamer-and-listings


1

Just add the \usepackage{color} line to your preamble, like this: \documentclass[a4paper]{article} \usepackage{listings} \usepackage{color} this works for me on Mac using latest TeXShop and TeXLive.


2

The contents in your lstlisting environment need to be put within a frame environment. MWE \documentclass{beamer} \mode<presentation> { \usetheme{CambridgeUS} \setbeamercovered{transparent} } \usepackage{listings} \lstset{frame=tb, language=Java, aboveskip=3mm, belowskip=3mm, showstringspaces=false, columns=flexible, ...



Top 50 recent answers are included