{syntax} is about the principles and construction of the (La)TeX language.

learn more… | top users | synonyms

22
votes
2answers
15k views

How to highlight Python syntax in LaTeX Listings \lstinputlistings command

I am using package listings to import my Python source code into my LaTeX document. I use the command \lstinputlistings. I have a Python source like class MyClass(Yourclass): def __init__(self, ...
78
votes
2answers
18k views

When to use \par and when \\

What is the difference between \par and \\ and when should I use \par instead of \\?
11
votes
1answer
8k views

How to use symbols such as \delta and \lambda

I'm trying to use symbols such as \lambda and \delta but for some reason it's not compiling. I've reproduced the problem in the following code: \documentclass[12pt,a4paper,oneside]{article} ...
3
votes
1answer
5k views

\lstdefinestyle syntax highlighting

I´m new to latex and got the following problem. I defined a listing style for XML Syntax highlighting like this: How can I get also the equals symbol in the attribute color (orange)? I want to do ...
22
votes
2answers
22k views

How do I put text over symbols?

This is difficult for me to explain, but how do I put words over a symbol? For instance, I want to add words over an equal sign. Anyone know the command/syntax for that? Also adding ^ doesn't cut ...
7
votes
4answers
3k views

How can I display two single quotes in LaTeX?

I need to display two single quotes without anything between them (I'm preparing computer science lecture slides and I want to display '\''), but of course LaTeX wants to translate '' to closing ...
6
votes
1answer
1k views

Syntax error; pgfuseimage [duplicate]

Possible Duplicate: Include figure (from macro) with underscore in filename I am trying to make first presentation in LaTeX using Beamer environment. In order to include some graphics, I ...
8
votes
2answers
1k views

How to highlight (colorize) the syntax of configuration files (like .ini or .conf)?

I need to highlight the syntax of files containing lines with parameters and their values in LaTeX. Let's say I have a following file: # some comment parameter1 = value of parameter1 parameter2 = ...
3
votes
1answer
200 views

Single quotes around math?

I am using the syntax package, and I want to define a grammar like: Rule = Head -> Tail but when I do this: \begin{grammar} <rule> ::= <head> `$\rightarrow$' <tail> I get ...
5
votes
1answer
613 views

How to render Android listings with syntax highlighting?

I need to include the source code of a bigger Android project in the documentation written with LaTeX. Do you recommend any particular package that is capable of highlighting Java code and which also ...
5
votes
2answers
2k views

Syntax error; Undefined control sequence \EndIf

I get the following error when I compile: Syntax error; Undefined control sequence \EndIf Code: \usepackage{algorithm2e} \begin{algorithm}[h] \label{FecEncodeAndSendFECUnits} \caption{Function ...
5
votes
1answer
188 views

.bst function to strip LaTeX command from string

Is there a preexisting .bst command to stip all LaTeX commands from a string? For example, if the string on the top of the stack is "Hello \textsc{ladies}" I'd like to replace it with just "Hello ...
22
votes
3answers
717 views

Why are text format commands used inside braces?

Most commands in Latex are written with the arguments inside braces following the command: \command{arguments}. But text formatting options, like \em, or \scriptsize are usually written inside the ...
13
votes
1answer
65k views

How to write a not equal to sign in Latex pseudocode

How do I write not equal to sign (equivalent of != in C) in Latex pseudocode.
5
votes
1answer
181 views

Bracket position rule

What is rule in specifying bracket position: \foo[]{} %or \foo{}[] Following syntaxes are clear, is there any other combinations? \foo{}{} \foo{} ...
4
votes
1answer
374 views

listings wrong syntax highlighting in perl - format specification

Perl uses '#' as an introduction for a comment, but also as a format specification. This produces problems in the syntax highlighting in the listings-package. How can I fix it? ...
0
votes
1answer
446 views

Smalltalk syntax highlighting for Latex [closed]

What is the easiest way to format Smalltalk syntax using the listings package?
0
votes
0answers
68 views

what does an asterisk (*) character do in a renewcommand? [duplicate]

Possible Duplicate: What's the difference between \newcommand and \newcommand*? I've seen * used in memoir.cls: \renewcommand*{\chapnumfont}{\normalfont\HUGE\sffamily} and ...
4
votes
1answer
159 views

What is the proper way to format syntax within ConTeXt?

For some time, I have thought, perhaps mistakenly, that the precise placement or spacing around ConTeXt syntax was unimportant, e.g., under this assumption, all of these should produce the same ...
7
votes
1answer
384 views

Different syntax for nodes with pos=x on a path with (A) — (B) and (A) to (B)

I wonder why we need a different syntax for specifying nodes (and coordinates) on a path when using the simple -- and the .. controls … system or the to operation. Here’s an example to illustrate the ...
6
votes
1answer
521 views

How to enclose terminal symbols within circles and/or nice oval boxes in a syntax diagram built using syntax.sty?

I hope you can help me again. I want to use the syntax package to build syntax diagrams, but I want to enclose non-terminal symbols in boxes and terminal symbols in circles or well-formed oval boxes ...
2
votes
1answer
204 views

Looking for macros to typeset syntax in more conventional way

I want to create a note about PSTricks and I need macros to typeset syntax in more conventional way that is adopted by most computer scientists. For example, I need a pair of > and < but they ...
3
votes
1answer
316 views

Syntax: De-highlighting Certain Commands in TexShop

There seem to be commands of various quality. A command like \section has some structural effects and differs considerably from commands like \dots or author-defined shortcuts (for example \eg for ...
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. ...
2
votes
1answer
1k views

Using “listings” package to colorize the source code of ANTLR grammar file?

I use listings package in my diploma thesis for source code. Besides the mainstream languages like Java and C# I also need to include the sources of the language grammars (.g) which are pure mark-up ...
33
votes
3answers
4k views

What is the difference in citing/referencing with or without tilde?

I've seen examples referencing a table as follows: Table~\ref{table:overview} shows an overview of all the elements. What is the use of the tilde in front of \ref or \cite and when do you have to ...
16
votes
3answers
756 views

Short version of emph?

Is there something like a short version of \emph? What I want is something comparable to \lstShortInline or what the shortvrb provides, just not for the \verb command but for the \emph command ...
1
vote
3answers
478 views

Syntax doldrums

I am a long time user and fan of LaTeX, but I hate the syntax! I wish it could be more like Python or Haskell. The syntax of those programming languages is much more readable than LaTeX which is ...
6
votes
1answer
428 views

What does a number followed by “ in” mean?

The TeX syntax highlighter that I use colors all occurrences of a number followed by " in", e.g. 0 in or 32 in in a dangerous bright red, in almost all contexts. Why?
2
votes
1answer
4k views

A package for formatting Linux terminal excerpts?

I know about minted and listings, but either of those are intended for formatting of programming languages excerpts. Is there a package that would do the same for Linux terminal excerpts? Such as: ...
7
votes
2answers
6k 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 ...
2
votes
2answers
1k views

TeXShop foreground color can't be set to desired default

Among the IDE's I've tried, TeXShop wins it for me as of now. Except for a small but very important customization: setting the foreground color. I dig through ~/Library/Preferences and find ...
3
votes
2answers
2k views

How to set indentation within grammar environment?

I'm using mdwtools and syntax package to write BNF grammar, I wonder is there a way to set the parindent so that each production line will be center algined instead of left aligned by default? ...
23
votes
3answers
10k views

Which package can be used to write BNF grammars?

I googled and found two packages: mdwtools bnf Unfortunately, both of them have extremely poor documentation. There are only one to two examples for each one, which makes it hard to follow. ...
9
votes
2answers
3k views

Why \land instead of \and?

I recently asked the logical and character in TeX and got \land as the answer. My question is, why \land, and why not simple \and? I mean, does l here refer to something technical, or historical, or ...
19
votes
3answers
21k views

Logical “and” character in TeX

I'm trying to write a logical syllogism in the form of ((a -> b) & (c -> a)) -> (c -> b). But I don't know how to write Logical And character. It's something like caret character (^), but not as a ...
78
votes
4answers
3k views

Techniques and packages to keep up with good practices

Question What techniques and packages are there to keep up with good practices? What I already know I already know of the following packages for this kind of purpose: ...
6
votes
2answers
2k views

Is there a LaTeX package to format computer language grammars?

I need to display BNF grammars, but couldn't find any LaTeX package that does this.
15
votes
3answers
2k views

How to add custom C++ keywords to be recognized by Minted?

I have defined several structures and types in a C++ project. I have to write some documentation for this code, and I use the minted package to typeset my code. I would like to be able to add some ...
9
votes
3answers
3k views

Ruby highlighter for LaTeX

I'm looking for a package that can highlight ruby source code in LaTeX. I've found this thread: http://stackoverflow.com/questions/1966425/source-code-highlighting-in-latex But it is from 2009, and ...
5
votes
3answers
2k views

Using keywords including a dot in the name with the listings package

I am using the listings package which works like charm in most cases. I tried to define new languages for my needs with the help of morekeywords options in \lstset, but entering special keywords ...
5
votes
2answers
482 views

lineno and syntax package incompatibilities

I'm using the syntax package from the mdwtools version 1996/05/17 1.07. I successfully set the properties to show a grammar definition properly but then when I try to combine it with the lineno ...
10
votes
2answers
3k views

What is the difference between \fboxsep=1cm and \setlength{\fboxsep}{1cm}?

Question has been written above.
159
votes
4answers
8k views

What is the use of percent signs (%) at the end of lines?

I see that the code in many packages and examples contains percent signs % at the end of (many) lines. What are they used for? Do they affect the parsing of those lines?
18
votes
4answers
3k views

How to make a real backslash (escape) character?

I just want a good way to make a backslash character (or whatever character(s) any given format uses as escape characters), suitable to \write to a file or pass to a pdfTeX primitive. Let me ...
54
votes
5answers
55k views

How to escape the & (ampersand) character in BibTeX?

I would like to put a & character in a BibTeX publisher tag. Thus far I have tried: \& {&} {\&} "&" with the full value enclosed in curly braces and double quotes. No matter ...
3
votes
1answer
1k views

Where is \textunderscore defined ?

I just started TeX recently and I'm reworking a legacy TeX-piece (book , second edition). I create lots of TeX-tables (with SAS) and do \input them. The tables contain many \textunderscore s. All ...
19
votes
3answers
2k views

Typesetting LaTeX Source Code with the listings package

I am writing some documentation for a LaTeX package, in which I am going to be including some example LaTeX code. What is the best way to typeset that code? I know I could just use verbatim, but it ...
11
votes
5answers
712 views

How do I print a syntax-highlighted LaTeX source file?

I want to print an example source file so that I can study it. How do I print it with syntax highlighting? I'm currently using TeXShop in MacTeX; apparently it doesn't have this ability. What program ...
13
votes
5answers
1k views

Use column-separator & (ampersand) inside \newenvironment

I'd like to define a grammar environment which basically wraps a tabular environment. Inside the grammar environment I'd like to use an environment called production to insert rows. Example: ...