{code} is about using LaTeX to format and display source code. For questions about TeX itself as a programming language, use the {programming} tag.

learn more… | top users | synonyms

0
votes
0answers
21 views

How can I Autoident in TeXstudio?

I am a new LaTeX user. How can I auto-indent all my LaTeX code in TeXstudio? have TeXstudio an auto function ?
2
votes
1answer
43 views

Inline python code in latex

I am trying to add some inline python code into my report with color in an box like following: As you can see "matrix text is red coloured embedded in a box" I can add inline colour code using the ...
0
votes
0answers
47 views

What is this please? [closed]

context.getContentResolver().delete(MediaStore.Files.getContentUri("external"), MediaStore.Files.FileColumns.DATA + "=?", new String[] { path });
2
votes
2answers
88 views

Force latex to parse command as raw text

I'm writing a text about programming and want to include some inline small code snippets. In markdown one would simply use backticks for this test. This automatically becomes monospace font. I want a ...
0
votes
1answer
25 views

Unable to include “large” code in lyx files

Following this question I was able to insert (Java) code into my lyx document. However, when I try to visualize (export it as a .pdf) the following error comes up: I can't work with sizes bigger than ...
1
vote
1answer
41 views

Format code listing package

I am documenting a script which has almost 43+ keywords. The output I want is something on the below lines... and the latex code I have is \documentclass[a4paper, onesided]{article} ...
0
votes
0answers
39 views

Is it possible to use tikzmark inside minted?

As I've pointed out in a related question, I'd like to have some arrows pointing to parts of a source-code listing. I know this is possible with the listings package, but is it possible with minted? ...
3
votes
2answers
114 views

How to draw over minipage in tikz?

I've got a code snippet, that I'd like to annotate with arrows, boxes, and bubbles pointing to the various parts of the code. Right now, I've got the code in a minted environment, inside a minipage, ...
1
vote
0answers
38 views

Help identifying LaTeX code-style feature

The document below uses a feature I can't quite identify to display monospaced code-style font sections: Does anyone know how to achieve this effect?
2
votes
2answers
82 views

insert code keywords inline

What is the command to insert inline code words into the text like this? I know there are packages for inserting snippets into the code, but I only words within the main text. I was wondering if ...
4
votes
1answer
80 views

Setting style for Python docstrings in lstinputlisting environment

I am using the listings package for source code in my LaTeX document. I am trying to set the style for docstrings in the Python programming language: \documentclass{article} \usepackage{listings} ...
1
vote
1answer
84 views

Latex with free draw support for note taking

I'm self studying math and computer science and am wondering how people like to organize their notes. This is because sometimes math is very symbol heavy and hard to write out, but sometimes it's ...
2
votes
0answers
36 views

Tangle source code from PDF for literate programs

I want to include raw source code text that can be extracted from a PDF. It looks like this might be possible using PDF layers or OCQ or some kind of accessible option but I can't find a TeX package. ...
2
votes
2answers
31 views

How to get continuos line numbers for minted code blocks

I use minted in following way: \documentclass[a4paper, 11pt, twoside]{article} \usepackage{xltxtra} \usepackage{xunicode} \usepackage{polyglossia} \usepackage[svgnames]{xcolor} % Syntax higlight ...
2
votes
1answer
31 views

How to add background for texttt (and allow line breaks)

I use texttt{} to write names of software, commands etc. within the text. Sometimes the texttt text is longer and there is a line break within it. It works well, no problem here. I wish to add ...
1
vote
2answers
23 views

Minted “underfull \hbox (badness 10000) in paragraph” when using bgcolor [closed]

When I use minted to highlight BASH code like this \documentclass[a4paper, 11pt, twoside]{article} \usepackage{xltxtra} \usepackage{xunicode} \usepackage{polyglossia} \usepackage[svgnames]{xcolor} ...
5
votes
1answer
68 views

Using different colors for different keywords in lstlisting

I've looked through a few answers on here, and either they don't work or don't fully answer my question. I have to format some C++ code and I want it to have these colors for these specific keywords ...
2
votes
1answer
33 views

Crossreference \lstinputlisting code

I frequently need to put C code into my document, so I defined, \newcommand{\Ccode}[1]{\lstinputlisting[backgroundcolor=\color{gray!5},caption=\texttt{\lstname},language=C]{C/#1}} in my document ...
1
vote
1answer
83 views

write “Mi_dark energy” in a text paragraph [closed]

I would like to write "Mi_dark energy" in a text paragraph. How should I do? I thought maybe but \(Mi_\text{dark energy}\) but it doesn't work. What did I miss out? Thanks.
1
vote
0answers
27 views

tcolorbox, not displaying symbols in listings (using minted) [closed]

I have the following latex code \begin{ipythonnb} \begin{ipyin} A = np.array([[3, 2, -1], [2, -2, 4], [-1, 0.5, -1]]) b = np.array([1, -2, 0]) np.linalg.solve(A,b) \end{ipyin} \begin{ipyout} array([ ...
2
votes
0answers
20 views

\mintinline expands to a single newline

I'm using Minted 2.1, that I have installed through tlmgr, and Texmaker 4.1. Compiling the following piece of code (straight from the documentation) : \documentclass{report} ...
1
vote
0answers
35 views

Why \@M instead of 10000? [duplicate]

Reading code from packages/whatever, I often find commands like \@M, \p@, \z@, \m@ne, \@ne, \tw@ etc. What is the point in using those instead of the (IMHO more understandable) 10000, pt, -1, 1, 2 ...
0
votes
0answers
18 views

Pygments for markup of Lua source code - how to get styling information and the necessary macros using ``pygmentize``?

I wanted to use Pygments (specifically via the pygmentize tool) to mark up some Lua code for inclusion into a LaTeX document. Based on what I understand, pygmentize can either output a full document ...
1
vote
1answer
108 views

Fitting codes in a Latex Code block

\usepackage{listings} \begin{document} \lstset{language=Java} \begin{lstlisting}[frame=single] PDDocument doc = PDDocument.load(file); String ...
2
votes
0answers
15 views

Incorporate domain name in lstlistinput

I have some bash code which I want to incorporate in my document but I want to include the command followed by the output. For simplicity let yous the code ls. I have my code in a txt file which I ...
7
votes
1answer
76 views

Listing creation fails with “dimension too large” given a large block of characters

When creating a code listing, we recently ran into a strange error from the listings package. Specifically, listings bails out on a large block of text. Here's a minimal working example: ...
2
votes
1answer
42 views

ERT code not working in a particular document

I wanted to use biber as a bibliography processor in Lyx and that involves some manual settings as explained here . The last bit invloves inserting a LaTeX command \printbibliography in ERT (TeX ...
2
votes
0answers
32 views

Listings - Including only part of an external file between certain points

I've just started using LaTeX and am using the Listings package to include external source code. I would like though to only include certain parts of the source code. I know that certain parts of the ...
1
vote
0answers
32 views

Issue with lstdefinestyle{XML} and margins [duplicate]

i am having troubles inserting XML code in Latex because the code lines appear out of the margins. First at all, i have defined the style, by the following way: \documentclass[a4paper,11pt]{book} ...
0
votes
1answer
43 views

Font size of inline code-listings too small

I'm using the listings package and am satisfied with how my code listings look. The font in my inline-listings however is too small compared to the rest of the text. How can I only increase the font ...
1
vote
1answer
53 views

Create generic containers that dynamically expand for text

Problem: I am trying to create color containers that can hold text that vary in size. What I have not been able to figure is what method you should use in order to achieve this. Example 1: ...
1
vote
1answer
38 views

missing minus sign in R code using latex

I'm using lstlisting to include my R code in my LaTeX, however, the minus sign after < is not appearing in the compiled file. \usepackage{listings} \begin{document} \begin{lstlisting} ...
2
votes
1answer
60 views

lstlisting framed with the caption inside the frame

How do I made a lstlistings look like following? The best I could get was: The code for the second image is: \begin{lstlisting}[caption=id(in), frame=single] out <- in; return out; ...
1
vote
1answer
52 views

Making text appear in a box [duplicate]

Sorry if this is similar to previous questions, but I need to check if this is the best solution. My issue is that I am writing a document which contains HTTP messages for example of a snippet: ...
4
votes
1answer
130 views

How can I make listings look like minted?

Up until now I used the listings package for my code-listings. Today, I tried minted and I'm pleased with the default look. Since I'd have a lot to do to switch from listings to minted at this stage ...
2
votes
1answer
53 views

hyperref to line number in listing imported from file

Can I refer to a line number from the imported file without escaping chars inside the file? Say, I import my file like this \lstinputlisting[language=c]{main.c} and I want to \hyperref{} line 50 ...
5
votes
2answers
172 views

How can I add a little code block instream with text?

I would like to add a little code block in line with paragraph text. For example: In order to do this just run the [code block] command in your terminal. Can anybody help?
2
votes
1answer
39 views

How should multiline pieces of code be put into a table?

I have the following two pieces of information that I would like to present side-by-side in a Beamer slide. I think I'd like these two things in two cells of a two-column table. Is there a good way to ...
3
votes
1answer
210 views

Undefined control sequence in Latex using programming code

Problem: Getting the error message Undefined control sequence. (\end{document}..). This occurs when I include the following code that prints out formatted programming code. If I remove this code the ...
5
votes
3answers
79 views

Centered line code with numbering

How I can center a line code and numbering it like in the picture? Is there a command that works inside a lstlisting environment? Really thanks in advance
0
votes
0answers
23 views

How to write “for” block with counter by Algorithmic package

How can I write a code like below using algorithmic package for (int i = 0; i < node.children; ++i) ..... I can't use foreach or forall because in a point inside the loop I should decrement i ...
1
vote
0answers
58 views

why is the text green in my code listing? [closed]

I use \begin{lstlisting} Type readable_t, writable_t \end{lstlisting} I want the text color to be black, but instead I get green:
3
votes
1answer
83 views

Exclude lstinputlisting

I want to save paper when I print my LaTeX file. That's why I want to hide all my code, inserted wtih lstinputlisting{} I already know how to exclude tables and images or math but the ...
0
votes
1answer
50 views

Defining keywords for SQL using listings

Problem: I use listings package to highlight SQL code but for some reason, unknown to me, I can't get certain keywords in SQL to highlight in a different color. Minimal Working Example: ...
1
vote
1answer
70 views

Macro/shortcut for defining text portion as code

I'm currently converting my thesis into LaTeX, and i have an issue: being an IT thesis, I have tons of code quotes. The problem is not about the blocks of code: they are not that many and i can wrap ...
1
vote
1answer
47 views

Add description to code tag

I didn't find answer how to add description to my simple code listing. It looks like that: \lstnewenvironment{code}[1][]% { \noindent \minipage{\linewidth} \vspace{0.5\baselineskip} ...
3
votes
1answer
48 views

How to indent formula in two different lines

Please see the uploaded photo. The formula is too long, so I have to let it breaks to the second line. However I want to indent the two formulas, so what should I do ? Please help me. Thanks.
1
vote
0answers
22 views

Is there any smart way to dynamically define lines in listing? [duplicate]

I'm using lstinputlisting to include code examples in my thesis, but as I'm working on the text and the code simultaneously, the code is not yet fixed in length. Is there any way that I can define a ...
1
vote
1answer
93 views

Set italic and bold inside of \lstlisting

The following effect is what I want: And I wrote corresponding code as below \begin{lstlisting}[mathescape] \textbf{Document} ::= <Document [\textbf{\emph{documentName}}]$_0^1$ ...
0
votes
0answers
25 views

Insert BNF to paper [duplicate]

I want insert the following BNF into my paper.And I wrote corresponding code as below. The following code has many problem and can't work. I think there must be some simpler ways to implement. ...