{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

2
votes
0answers
24 views

Adjust vertical spacing between caption and listing in KOMA (scrartcl)

In the standard article class the distance between caption and the listing below it is fine. But when using KOMA-Script's documentclass scrartcl the vertical space is too big (see the image below). I'...
3
votes
1answer
43 views

ConTeXt : inline code highlighting with t-vim

I am trying to insert code in a ConTeXt document, so I tryed to use the vimtyping module. It works well for text blocks, but not for inline text, since it makes a new line. Here is my MWE: \...
-1
votes
0answers
35 views

Pseudo-code in latex

Could you help me to write this pseudo-code in latex please? Thank you
3
votes
1answer
65 views

how to code left facing bracket of values with single value to its right?

How can I make a vector in this form?
3
votes
2answers
67 views

How can I recreate this code example given in this pdf? Vertical lines in verbatim?

I'm referring to the pdf linked here. Specifically, how can I recreate this part on the first page? I'm guessing it's using the verbatim environment somehow, but how can I get those vertical lines ...
2
votes
0answers
37 views

Formatting Code around Line Breaks

I am typing up a sentence which contains code, and \verb's ignorance of line breaks is annoying me. This code is very short, and it does not make sense to give it its own line, but I also do not think ...
0
votes
0answers
41 views

How to create a specific code listing macro

I am trying to reproduce a macro in latex that would allow to insert code in this format: So there is a header with listing number that is starting from the left side of the document. It is between ...
1
vote
0answers
34 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.
1
vote
0answers
43 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
35 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
31 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
vote
1answer
44 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
32 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{...
3
votes
1answer
70 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
620 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
30 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
57 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
140 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
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
153 views

How to code arrows from one letter to another letter? like in the image below. How do I code arrows from letter U to X?

If you look at the image below, How do I code arrows from letter U to X?
5
votes
1answer
133 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 - ...
0
votes
1answer
26 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 ...
5
votes
1answer
328 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
38 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
50 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
74 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 ...
1
vote
2answers
53 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 ...
17
votes
2answers
512 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?
1
vote
1answer
70 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
283 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
35 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
41 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
37 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 ...
0
votes
1answer
107 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 ...
1
vote
1answer
24 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
42 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
83 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
28 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
83 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
284 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
41 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
63 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
48 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? ...