The tag has no usage guidance.

learn more… | top users | synonyms

11
votes
5answers
2k views

How to write a code to find the Pythagorean Triples

I want to write a code to make a table contains Pythagorean Triples (see picture) automatically. That is mean from the formulas $a^2 + b^2 = c^2$ , we can get the Pythagorean Triples I used ...
1
vote
1answer
36 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: ...
0
votes
1answer
13 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
0answers
24 views

Post a question based on another tex file - Eg. Legrand Orange Book template [closed]

If you modified the Legrand Orange Book template to include other environments, and are getting errors based on the new environment, how do you post your code? Thanks.
1
vote
1answer
23 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} ...
3
votes
0answers
46 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
22 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
37 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: ...
2
votes
1answer
30 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
157 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?
25
votes
2answers
21k views

How to format an inline source code

I have a document where I quiet often refer to source code element, such as class names, I wanted to format these strings differently, but at the beginning I didn't want to fiddle with various options ...
2
votes
1answer
29 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
89 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
69 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
14 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
47 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
71 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 ...
1
vote
1answer
63 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 ...
0
votes
0answers
22 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
28 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
43 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 ...
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. ...
0
votes
1answer
28 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
24 views

Insert XML code to paper [duplicate]

I use the following set to insert xml code to paper \usepackage{listings} \usepackage{color} \definecolor{gray}{rgb}{0.4,0.4,0.4} \definecolor{darkblue}{rgb}{0.0,0.0,0.6} ...
4
votes
2answers
182 views

Aligning table within latex editor

Suppose I have the following table in my TeXstudio editor: Latex & 360 & 101.77 & 10.71 & 101.86 & 64.60 & 127.20 \\ Manufacturing & 360 & -7.33 & 12.59 ...
11
votes
3answers
415 views

End \verbatim command

The verbatim environment is used to display LaTeX commands instead of having them executed. To display a single command in-line, the \verb|| command can be used. To display a whole block, we can use ...
2
votes
0answers
61 views

How to write the signature of a method in LaTex?

I'm writing an article in LaTex about programming and I need to write the signature of a C++ method using a specific format, only the statement of the method, not the body. for example: void ...
3
votes
1answer
52 views

Backwards quotes in embedded C code

I used the csquotes package to make all double quotes curl the right way in the body of my document, but in the embedded code it doesn't work. I tried the slanted quotes and they don't work either. ...
1
vote
1answer
75 views

Define starting line number when using mcode.sty to display Matlab code and referring to the code

I want to include parts of my Matlab code in my LaTeX document using mcode.sty. Here's a MWE: \documentclass[b5paper, 10pt, twoside, openright, dvipsnames,cmyk]{report} \usepackage{listings} % Is ...
1
vote
2answers
34 views

Rotate code on file in lateX document

I want to include a file with Haskell code to my LaTeX document. Unfortunately, the code taking to much space, so I wanted to rotate it to have a landscape format, but somewhat, the code is almost ...
1
vote
0answers
77 views

Good looking LaTeX code [duplicate]

I'm looking for some script (program) which would help in editing LaTeX code. Usually I have a mess in my .tex code, so it would be good if the script could align tabulars and so on. It would also be ...
3
votes
0answers
59 views

How make formulas in the PDF not selectable?

Mathematical formulas in a PDF from LaTex generate lots of noise while reading it with Text-to-speech software. This is why I would like find a way to make all the set of symbols inside the formulas ...
5
votes
1answer
98 views

Referring with cleveref to a custom listing (\lstnewenvironment)

I use cleveref's \cref command for referencing, and \lstnewenvironment to create a new listing type. My document has multiple types of listings, each of them with their own counter. However, cleveref ...
3
votes
1answer
69 views

Non-curly quotes in code?

Here is a quick question, how to use tex to print this ' symbol? An example is shown below: data 'a list = Nil | Cons (e, 'a list) I tried to use ' or `, but they all looks bad.. I am sorry but I ...
2
votes
1answer
94 views

bound width of a single lstlisting to one column inside a two column IEEE template

I use IEEE double column template and inside it I add a C++ code. I expect the code to be bounded within a single column however it infringes to the next column. How to fix this code? I would avoid ...
9
votes
1answer
611 views

What is this code fragment for?

Taking a look at the code of the package ifxetex, I found the following: \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax\else ...
2
votes
1answer
105 views

Maple 18 output in LyX

I have the following problem: I want to import the outcome of solve(b^4-(2-d)*b^2-2*d*b+d+1 > 0, [b], parametric), which is a maple code, into Lyx. Even though I managed to export the solution of ...
5
votes
1answer
146 views

Not colored digits after characters in lstlisting code

I am writing a LaTeX document with Verilog code and I would like to have colored digits in these occasions: simple digits (for example # 30) bus (for example [3:0]) binary or hex representation ...
9
votes
2answers
4k views

Which package to use for writing algorithms?

I am looking for a package that will allow me to write pseudocode of algorithms. The pseudocode may include mathematical symbols, like \forall, \in and subscripts. But I would like also to "talk" ...
2
votes
0answers
94 views

How to transform a mathematical expression from LaTeX code to Maxima code?

How to transform a mathematical expression from LaTeX code to Maxima code? For example, convert \frac{8x^3-4x-2}{2x} in LaTeX to (8*x^3-4*x-2)/(2*x) in Maxima, but automatically.
0
votes
2answers
238 views

How to include lambda calculus code in LaTeX?

What is the best way to include lambda calculus code in LaTeX (like in Courier new font), especially one that allows for the use of math symbols as well like $\lambda$ throughout the environment. For ...
66
votes
3answers
5k views

Are there any coding style guidelines for LaTeX?

I have been using LaTeX for a long time now, but still all my document files look a bit messy. Now I want to get rid of this bad habit and get some order into my code. That is why I am wondering ...
13
votes
3answers
4k views

How to make a single word look as some code?

I would like to be able to make a single word in a text look like a coded word. Is there any command such as \code{...} which allows me to do so? (basically, I want to produce something like above ...
6
votes
1answer
136 views

Minted inside tabular

I know this question has been asked before, but it didn't quite solve my issue. (How to embed a minted environment inside a tabular environment?) The described workaround (bringing \end{minted} to a ...
2
votes
1answer
189 views

Lyx code tag with highlighting for C

I just installed Lyx and when I try to insert the program I observe that there is no syntax highlighting. What is the best way to allow for syntax highlighting in LYX?
1
vote
1answer
189 views

lst include has first line indented [duplicate]

When I'm including a source file, by way of \lstinputlistings{file/path/to/file} However, This results in the following below: Why is the first line not being formatted correctly? And how do i fix ...
1
vote
0answers
41 views

Inserting a stand alone code file using lstlisting

I am in the process of writing a report on a project and need to include the final code used in an appendix. The final code while not yet complete, is lengthy enough that I would like to just use ...
3
votes
0answers
69 views

How to use same font-style with escapechar in lstlisting?

Original Question I want to highlight something inside a C++-comment in a code-listing. \documentclass[a4paper, 12pt]{article} \usepackage{color} \usepackage{listings} ...
0
votes
1answer
50 views

Replicate pseudocode

I was looking for some LaTeX code to replicate the result shown on the image below. This image is taken from the book "Temporal Verification of Reactive Systems - safety"