The tag has no wiki summary.

learn more… | top users | synonyms

55
votes
6answers
2k views

How bad for TeX is omitting braces {}, even if the result is the same?

Sometimes writing braces and omitting them produces the same result: \tilde{\psi} \mathrm{e}^{\mathrm{i} \pi} vs \tilde \psi \mathrm e^{\mathrm i \pi} Or (taken from Werner's comment below) ...
55
votes
3answers
3k 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 ...
33
votes
3answers
4k views

LaTeX code sniffer and/or beautifier?

I'm looking for a LaTeX code sniffer and/or code beautifier, because I'm creating a CI server for my LaTeX books and I wanted a few things. :D
28
votes
5answers
2k 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 shoud not be that hard, but I cannot seem to program ...
24
votes
2answers
864 views

How to understand and write LaTeX code?

LaTeX is like a language. In order to write LaTeX code I have to understand the "word" and the "sentences structure". I have searched on wiki, some LaTeX books, but they just give the LaTeX command, ...
22
votes
1answer
8k views

How to properly code a TeX file, or at least avoid `badness 10000`

I'm coding a TeX file and although the .pdf is correctly rendered, I'm using "stone age" tools to code it. As some examples, I use \\ to leave a line space between two paragraphs, or \noindent in ...
19
votes
2answers
1k views

Print programs with its proper syntax

I have defined my own language whose syntax is very close to the one of Pascal. I would like to type the following program for instance. Many people use the packages algorithmicx or algorithm2e to ...
19
votes
2answers
3k 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} ...
18
votes
2answers
12k 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 ...
16
votes
4answers
663 views

Is this branching code I wrote a bit obfuscated?

I've been away for a while and I forget if this sort of question is appropriate, but here goes. Recently I wrote some code (in expl3 but I hope it's clear enough) and in hindsight I wonder on its ...
14
votes
2answers
3k views

\listings code style for HTML5 (CSS, HTML, JavaScript)

I would like to create a code style for HTML5 that can be used with the \listings package. An HTML5 document consists of three languages: CSS, HTML and JavaScript. That makes the whole thing a bit ...
11
votes
1answer
954 views

listings package: no numbering in case the code has only one line

I have a custom style in lstlisting with numbers on the left and the number step is set every line. I would want to know how the listings could appear without number in case the listing has only one ...
10
votes
1answer
325 views

How to show similar display of codes of different programming languages in LaTeX

I am very new to LaTeX and I am writing my thesis. In a chapter, I want to show my codes, which are in Mathematica. I use the listings package as follows: \documentclass{article} ...
10
votes
1answer
792 views

Code readability

I'm getting my head around LaTeX, and I find really awesome the fact that the documents are completely editable with a plain text editor, while getting a really neat and professional output. I'm ...
9
votes
5answers
682 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 ...
9
votes
3answers
323 views

Which package should I use for doing a connecting homomorphism diagram like this in latex

which package should I use for doing a diagram like this in latex:
9
votes
1answer
754 views

How to typeset LaTeX code inside a Table environment?

I wanted to typeset LaTeX code directly into my document, but without it doing something, i.e., I just want to show my code in the output. Now, I know there is the verbatim environment for code, as ...
9
votes
2answers
497 views

Two code blocks working syncronously

I need two code blocks in my beamer frame. One will be the code and other will be the output for each line of code. I want to uncover each code line and corresponding output line. So, first it will ...
8
votes
3answers
587 views

Writing source code in LaTeX as text

Is there a package that allows source code in LaTeX as text? I rather not use listings package because the code takes too much space. Copy/paste is tedious because the spaces are not preserved.
8
votes
2answers
1k 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 ...
8
votes
2answers
2k 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" ...
7
votes
2answers
2k views

How to typeset VBA code in LaTeX?

I have a lot of VBA (Visual Basic for Applications, the programming language in Microsoft Office) code which I have to add to my thesis in the appendix. I wonder how I can most comfortably list those ...
7
votes
2answers
5k views

Code Snippet IN Text

How do I show a code snippet directly in my text? I dont want to have an extra box for it like lstlisting or verbatim provide it. My example may should look like this: The class List.class is... ...
7
votes
3answers
180 views

How to construct the following table with title in LaTeX?

I would like to construct a table look like the picture below: The code below represents my best attempt so far (the words in the table don't really mean anything): \resizebox{9cm}{!} { ...
7
votes
3answers
999 views

How to properly display backticks in verbatim environment?

I am preparing a beamer presentation where I need to display some markdown code involving backticks. Specifically, I want to show backticks in the verbatim environment. However, LaTeX renders them as ...
7
votes
1answer
1k views

How do I get colorized syntax highlighted code in pdfLaTeX

I'd like to get syntax highlighted code in LaTeX, but want to preserve the monospaced font (no curly quotes either). pygments doesn't seem to have an option to avoid curly quotes that I could find. ...
7
votes
1answer
677 views

How to make LaTeX code from the pdf file?

I am now on a project on translation a book from English to my native language. I always tried to do it as nearest to the orginal book as possible, and I used LaTeX for that. But my attempt failed, ...
7
votes
2answers
4k views

Insert Bash code with coloration into my latex report

I am writing a long report and I need to include some codes I programed. I would like present my code with coloration, as we can have in some text editor (and not using verbatim). I need the ...
7
votes
1answer
656 views

visualize code indentation

How can I visualize code indentation? What I want is to draw a vertical line along the indentation. Since an example is easier to show then to explain you can see one in this paper (on page 2)
6
votes
1answer
377 views

Is there an alternative to LaTeX which isn't whitespace sensitive?

I have been using LaTeX for about a year now, and I quite like it. However, I like to space out my source code. In most languages, this doesn't cause an issue, as extra newlines don't affect meaning. ...
6
votes
3answers
244 views

How to keep tables readable in code

What is the best practice for creating and updating tables in Latex? I am using Texmaker but I find it hard to update a table like adding entries or adding a column. I have to count entries which is ...
6
votes
5answers
4k views

Aligning pseudocode in LaTeX

My algorithms class is following strict guidelines for pseudocode. Let's say I have something like the following: y = 0 for i = n downto 0 y = a_i + x * y I want this to appear left-aligned on ...
6
votes
1answer
225 views

Command for the table Ruffini-Horner algorithm

I am trying to code a command in LaTeX to type the tables used in the computation of the Ruffini-Horner algorithm. You can see in the Wikipedia link above that these are rather simple tables. There is ...
6
votes
1answer
82 views

Macro, new command or new environment for code?

I am using the listings package to typeset code. I have defined a custom style using \lstdefinestyle{verbo} and then typeset code in a lstlisting environment as in the following MWE. ...
6
votes
2answers
4k views

Is there a way to enable syntax highlighting coloring in Lyx for program listings?

I want to embed a small program listing and have used Insert -> Program Listing in LyX's menu for that. The settings dialog supports selecting a language (Java), but I can't actually see any ...
6
votes
1answer
82 views

What is faster? To \RequirePackage{foo} or to check if the user has actually request it and \Require it if so?

I'm asking this because the package lineno has a thing that leaves a lot of commands in the .aux file (see here)... and I'm not sure if I should \newcommand these to empty or if I should just load the ...
6
votes
1answer
353 views

Hyphenation of long Java identifiers

What is the best practice for hyphenating long identifiers like Character.isJavaIdentifierStart when they appear in body text? I am aware of the path package that also deals with otherwise active ...
6
votes
1answer
808 views

Problem about program code included in LaTeX

I have some Matlab code which I would like to include in my LaTeX document. I use fancyvrb package, based on which I define a new environment called code. An complete and minimum example is: ...
5
votes
5answers
7k views

Verbatim environment with correct tab handling and special characters

I'm looking for an environment similar to Verbatim which will allow me to say something like the following code (which uses indentation instead of spaces): \documentclass{article} ...
5
votes
2answers
2k views

How to pass definitions to \AtBeginDocument?

I need to delay execution of a chuk of code to the time when other packages are loaded so I wrap it into \AtBeginDocument: \AtBeginDocument{% \def\reserved@a#1#2{% \edef\reserved@b{#1}% ...
5
votes
1answer
3k views

Fortran syntax highlighting in listings

I've got some Fortran 90 source code I want to put into my thesis appendix. For this I'm using the listings package. Is it possible to have colored syntax highlighting for the Fortran code?
5
votes
1answer
115 views

“Listings” environment for GAP

I was searching the web for a possible environment where I can put my GAP (Groups, Algorithms, Programming) codes. The most promising I saw was the "listings" package. But to my disappointment, this ...
5
votes
1answer
322 views

Problem formatting java code in my latex document (overshooting the page)

My code is being formatted in a way that makes it drift off the page when it's too long rather than just jump to a new line. I have tried lots of different things, pasted all kinds of examples from ...
5
votes
1answer
2k views

Environment code undefined

Why do I get ! LaTeX Error: Environment code undefined. when I use: \documentclass[10pt,a4wide]{article} \usepackage{a4wide} \usepackage[utf8]{inputenc} \usepackage[portuguese]{babel} ...
5
votes
2answers
368 views

Aligned, hanging indents in non-monospaced code

I want to typeset a piece of code containing line breaks. New lines should indent to a specified point in the previous line. Here is a monospaced example to illustrate what I mean. Notice how ...
5
votes
1answer
109 views

Is it possible to use the listings package incrementally in beamer?

Given a frame that has code rendered in a \begin{lstlisting}...\end{lstlisting} environment, is it possible to use beamer's incremental frame building feature to highlight code snippets? Here is an ...
5
votes
1answer
419 views

How to make my own LaTeX template?

Ok I know that my question is quite local, however, I have struggled with it for a long time and I could not find the answer, so I decided to post it here. I have to rewrite a book (which was written ...
4
votes
2answers
219 views

Is there a package for doing this in LaTeX?

I'd like to do something like this What would be the code? does it use a package for doing the $$f\mapsto f\circ \pi$$ part?
4
votes
2answers
102 views

Saving language preferences for inputing source code

Using the listings package, I am trying to input a Java source file into my document using a specified, user-defined style. This works just fine if I have the specified style definition in the same ...
4
votes
1answer
243 views

Cg Code in Latex

I am writing some document which contains Cg (C for Graphics) code in the document. I want to show the code in a neat highlighted mode. Any easy method to suggest? I tried the listings package but it ...