{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

1
vote
0answers
33 views

Anyone knows any “automatic” package to draw graphs of posets (the Hasse diagrams)?

anyone knows any "automatic" package to draw graphs of posets (the Hasse diagrams)? I know TikZ, but I wanted something faster (automatic). Thank you.
0
votes
2answers
44 views

Pandoc md to tex: code + enumerate interaction

How to make pandoc md to xelatex conversion understand that the code structure is within an enumeration list. The minimal code I've got in my markdown file. * Test your code * Don't use structures ...
1
vote
0answers
41 views

Removing the blank space after a definition (or something)?

already I researched a lot about it, but found nothing. Could you help me remove this white space to be between intem 3 and paragraph ("Quando não ....."). I thank you
1
vote
0answers
31 views

Include Doxygen syntax in LaTeX?

I want to write documetation for my current appliaction in LaTeX (about technologies i used and so on) and i wander if i could use section \mainpage of Doxygen in him, as a chapter " how to use " , ...
1
vote
0answers
28 views

How can I fill a page with a minted included json file?

I'm trying to add some huge json files to my document and have no idea how can I solve this two problems. Code: \linespread{1.0} \subsection{File xpto.json for X = 1} \label{ap:json_xpto1} \beCengin{...
3
votes
0answers
23 views

Eagle-i website citations in BibTex

I'm trying to cite some information from the Eagle-i website using BibTex. I realized they have many types of citations that seems not to match the BibTex entry types. For example, Eagle-i suggested ...
-1
votes
0answers
18 views

am having problem managing the margin around the code please help

[![ 1: http://i.stack.imgur.com/ZRFeY.png I am trying to publish matlab code but it's overlapping code in the next column. I tried to do it using tabular format but still no help. if there is any ...
1
vote
1answer
43 views

How to insert a number of column next to the post?

I think the question I'm going to do is very simple, but I had to do here because I researched about it all day and found nothing. Question: How is the code to make the graph below? I can not enter ...
2
votes
1answer
28 views

\lstdefinelanguage cannot handle keywords #if, #endif,

I need to insert C-code snippets in my LaTeX document. Therefore I define a C-code language syntax highlighting: \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage{color} \definecolor{...
30
votes
3answers
5k views

Code spanning over two pages with minted, inside listing with caption

I am trying using minted to display some code in my document, but the code is long and spans over two pages, this works fine, however when I place my code inside \begin{listing} \inputminted{java}{...
3
votes
1answer
64 views

Insert long Matlab code in beamer with scrolling window

I need to insert a quite long Matlab code in a presentation (for a course on numerical methods) and I would like to insert it using a rolling window, is it possible to do something like this in beamer?...
1
vote
1answer
43 views

How to enter a UNIX command

I am writing a tutorial, and I need to include a UNIX command which is run from the shell. How do I represent this? It looks extremely strange if I simply use the verbatim environment.
14
votes
3answers
600 views

Terminal screenshot generator

I would like to document work in console while I also think that bitmap images are not the best way to do it. They do not scale well and after all what I am trying to document is text. Therefore I ...
1
vote
1answer
28 views

Put two parts of source code in the same line

How can I have this behavior in LaTeX please : Two portions of code in the same line, separated by an arrow.
1
vote
1answer
48 views

copying a code to latex without loosing the format [duplicate]

I have a code of around 350 lines, and I need to paste it inside a LaTeX file without losing the formatting such as the extra spaces. What do I need to use to get this in LaTeX?
4
votes
2answers
139 views

Writing results of some code

I am doing some homework on Newton's method and would like to display results after five (or so) iterations. I was hoping for something along the lines of > 0.001 > 0.011 > 0.111 > 0.111 &...
3
votes
1answer
66 views

How can I get nomal form when I convert an array into an equation?

I have an array a & b & c & d & e & f & g and I want to convert this array in the form sqrt{a x + b} + sqrt{c x + d} = e with answer S=\{f,g\}. egreg helped me with this code. ...
0
votes
1answer
24 views

Generate multiple table of contents based on input to environment

With the following (pseudo)-code \newenvironment{A}[2]{\AddToToC{#1}{#2}}{} \begin{A}{Test1}{1} \end{A} \begin{A}{Test2}{2} \end{A} \begin{A}{Test3}{1,2} \end{A} I want to generate the following ...
0
votes
2answers
39 views

Code for a exchange protocol

Hi I want to insert a exchange protocol in my lab report. The protocol looks something like this : How can I write such protocol in latex?
2
votes
2answers
152 views
33
votes
6answers
5k views

How to produce a list of prime numbers in LaTeX

I would like to write a LaTeX script that produces all the prime numbers between the numbers n and m, where n < m. How can I do this? I feel it should not be that hard, but I cannot seem to program ...
5
votes
1answer
127 views

Code example, as in the TikZ/PGF manual, but extending to the width of the page

I am preparing a second "edition" of my minimal guide to TikZ and would like to have more professional looking presentation for the example. Thanks to Thomas F. Strun this is for the most part easy - ...
5
votes
1answer
325 views

Censor minted source code in pdf

I'm using minted in my publication to embed my source code examples with proper highlighting. Unfortunately, they are under non-disclosure agreement (NDA), so I have to blank them out before ...
0
votes
0answers
34 views

matlab-prettifier with fancyvrb-style of label / frame

I wonder how to make the frame line around caption of listing not being printed (top line being broken into two by caption in the middle) when matlab-prettifier (or listings package) are being used, ...
1
vote
1answer
49 views

Renew an already used label

Based on my question here my setup is currently looking like: \newenvironment{A}{\label{env:A}}{} \newenvironment{B}{ %%Pseudocode \if\thepage!=\pageofref{env:A} Pagebreak happened! \fi %% End ...
1
vote
1answer
26 views

Prevent tearing of environment

I have a custom environment, called test. The text placed in the environment should be kept together, even when placed in a multicol environment, i.e. if written as the following code OtherText \...
0
votes
0answers
19 views

Detect if environment contains a page break [duplicate]

Is it possible to detect if a custom environment goes over a page break, i.e. get a warning/something I can use for further processing (and preferably also tells me where the page break occurs)? \...
0
votes
0answers
60 views

minted not highlighting and inserting random characters in code

I am trying to syntax highlight some Haskell code in my latex document. The rest of my document works fine except for one section. I have the \usepackage{minted} command where my other packages are ...
0
votes
1answer
106 views

Any new packages for code listings

There are many questions (and answers) on this site about packages for showing listings of source code. But all the answers I have found are at least five years old, and I was wondering if any newer ...
17
votes
2answers
508 views

Python-like dictionary in latex?

Is there a command/macro in latex to generate python-like dictionaries, i.e. var = {a:1, b:2, c:3} which then return for \var{b} 2?
9
votes
3answers
15k views

Insert Bash code with coloration into my latex report

I am writing a long report, and I need to include some code I wrote. I would like my code to appear colorized, as can be seen in some text editors, but not by using the verbatim package. I need to ...
1
vote
1answer
56 views

How to insert code from a Router or a Switch

At the current time I have inserted the configuration of a couple of routers and switches using the following method: \lstset{breaklines=true} \begin{lstlisting}[frame=single] [Config here] \end{...
4
votes
4answers
276 views

Export source code of tex file

I have to create a training guide for Maple as part of an assignment. Obviously I need to hand in the final PDF document, but I also need to hand in the LaTeX source code to prove that I created the ...
1
vote
0answers
34 views

Unwanted coding shown next to inserted images on PDF, have no idea why? Pictures and code shown in description

Have this problem for all images except this one: I have tried PNG and Jpeg files, same problem. Here is the code us for the "count final.jpg" \begin{figure}[htp] \centering \includegraphics[...
0
votes
0answers
36 views

Making my LaTeX code look nicer (esp. line breaks) [duplicate]

I'm currently trying to improve the readability of my LaTeX code, and one problem I've come across is to do with the \ifthenelse command: Latex doesn't allow for line breaks in the code, so reading it ...
1
vote
1answer
37 views

How to not repeat word in \index

To make index I have to write word two times, \documentclass[12pt,oneside]{book} \usepackage{makeidx} \makeindex \begin{document} This will not print \index{anything} !!! However it will make an ...
1
vote
0answers
36 views

Best way to reuse and change code in a lot of documents

I would like to use in a lot of documents the same title page and some settings in a way that when I want to implement a change to take effect in all of them. One way that I thought is to place ...
1
vote
1answer
22 views

Set Keywords in two specific colors inside of a codeblock

Is it possible to set two Colors to Keywords inside of a Codeblock? I have the current settings for my Codeblock \lstset{language=[Sharp]C, captionpos=b, %numbers=left, %Nummerierung %numberstyle=\...
0
votes
0answers
38 views

How to create an index for a book that includes code chunks

I'm in the process of creating an index for a book that includes R code chunks. I'd like to include certain R functions that appear in these chunks in the index, so I assume I have to place the \index ...
2
votes
0answers
68 views

Start Matlab code directly from Latex

I'm using the documentclass beamer to make a presentation. Is there a way to start Matlab code directly from Latex? A button that I can press so that the Matlab code starts to run automatically? ...
2
votes
1answer
32 views

How can print this type of summation? [duplicate]

I am a new latex users and in a report must print this type of summation What is the latex code Thanks to Steven B. Segletes I have obtained this result: I need to reduce the space highlighted
0
votes
0answers
26 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
75 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 ...
2
votes
2answers
255 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
40 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 ...
3
votes
2answers
154 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
1answer
60 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} \usepackage{...
0
votes
0answers
46 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? ...
1
vote
0answers
53 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?
0
votes
1answer
56 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: \...