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

learn more… | top users | synonyms

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
189 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
576 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
1k 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
183 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
666 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
59k 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
176 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
345 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? ...
-1
votes
1answer
414 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
379 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
496 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
202 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 ...
2
votes
1answer
307 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 ...
30
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
733 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
470 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
398 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
9k 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 ...
17
votes
3answers
18k 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
1k 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
1k 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
469 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.
150
votes
4answers
7k 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?
17
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 ...
51
votes
5answers
52k 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
686 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 ...
12
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: ...
15
votes
1answer
444 views

Are there guidelines on how to read commented sources of LaTeX packages?

I'm trying to read source2e.pdf (texdoc source2e on the command line), but I'm stumped. It seems a rather mysterious tome to me. As I understand from this answer about what arguments a command ...
8
votes
2answers
289 views

How do I split a command into several lines and have LaTeX read it as only one line?

For example, I have a command which has a lot of options: \documentclass[option1,option2,option3,option4,option5,option6,option7]{article} I want to split it to several lines so I could read the ...
3
votes
2answers
446 views

When to use trailing backslashes

I am learning to use the puthesis document class. I have the following code: \documentclass[iupuiece,thesis]{puthesis} \begin{document} \title{The Theory of Everything} \campus{West Lafayette} ...
8
votes
3answers
385 views

A (La)TeX with only one special control character in the source file

One thing I find annoying about (La)TeX is that there are too many special characters. To have any of \ $ % & # _ ~ ^ { } in a text in the document we have to escape it using \. Personally I ...
65
votes
3answers
61k views

When should one use \verb and when \texttt

Sometimes people here use \verb!A SHORT COMMAND! and sometimes \textt{A SHORT COMMAND}. I'm unsure when to use which. Are there any guidelines or arguments for \verbatim vs. \texttt?
35
votes
8answers
3k views

Why do people use unnecessary braces?

I often see people creating new macros where the macro token is surrounded by braces. For example, \newcommand{\foo}{foo} This is unnecessary and I find the extra braces make it harder to read. Why ...
15
votes
2answers
618 views

New language - hyphenation

I'm working in a project (Ubuntu Manual, if you're curious) which requires TeX to create a PDF document. But when we have almost all translated, I've found that there wasn't an hyphenation pattern for ...