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

learn more… | top users | synonyms

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: ...
1
vote
0answers
43 views

Tab based syntax wrapper around LaTeX?

In text file formats, if one allows for tab based formatting one can simplify things considerably. Are there any simple syntax wrappers that compile directly to LaTeX? I'm thinking of something that ...
14
votes
1answer
188 views

How do I insert a tie (~) under expl3 syntax?

I need to define a token list of the form \tl_new:N \g_silly_tl \tl_set:Nn \g_silly_tl { Text ~ and ~ a ~ tie:?? } How do I do this? More generally, is there a reference where one can see how ...
1
vote
1answer
29 views

Can I query the current value of randomseed in Metapost?

Metapost allows you to set a seed for the random number generator, so that you can get a predictable sequence of numbers from uniformdeviate and normaldeviate. I can set it like this: randomseed := ...
11
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 ...
1
vote
1answer
197 views

Does underscore signify a function call?

What is the _ used to signify when following some sequence like \hat? The error I sometimes get leads me to wonder if it represents a function call, with whatever follows it being the arguments.
268
votes
8answers
24k views

Why is \[ … \] preferable to $$ … $$?

I've heard that you should use \[ ... \] for displayed equations instead of $$ ... $$, but why is that? I'd assumed that it's so that you can more easily tell which are starting and which are ending ...
70
votes
4answers
74k 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?
4
votes
1answer
39 views

Calculator package and Math Times Pro 2

When I try to use the calculator the mtpro2 package at the same time I get an error message. Recently I found out that this issue has something to do with the \SQRT command. ...
4
votes
2answers
71 views

Why \texttt and \verb giving errors when using with LaTeX commands inside their input

On latest version of MikTeX, following works: \begin{align*} \int sinxdx && \texttt{test line 1}\\ \int{sinx}dx && \texttt{test line 2}\\ \end{align*} But the following gives error: ...
6
votes
2answers
495 views

What is the role of an unescaped circumflex or hat character “ ^ ”?

Is there any use for the unescaped ^ in (La)TeX, when not in math mode? If not, I couldn't see why it's necessary to escape it.
0
votes
0answers
15 views

seqsplit error: \SQSPL@scani has an extra }

I created some commands to allow me to easily handle Japanese text in Latex. Recently I added seqsplit to automatically break lines, as Japanese text is handled as a single word due to the lack of ...
0
votes
0answers
14 views

When I am using {subfigure} option with \documentclass{report} it is working fine but if I use {subfigure} option with \documentclass{llncs}

When I am using subfigure option with \documentclass{report} it is working fine and I am able to use it but if I use subfigure option with \documentclass{llncs} then the figure numbers are increased ...
1
vote
1answer
57 views

Python code block outside of margin

I want to include some Python code to my Latex document. I have read this Tex Stackexchange question and added the following code to get syntax highlights: \usepackage{color} ...
0
votes
1answer
37 views

problem on numbering of equations

I am trying to write equations in latex: See this following code: \documentclass{report} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amscd} \usepackage{accents} ...
-1
votes
1answer
106 views

latex code diagram

It will be helpful if someone writes for me the code in latex for the following diagram and explain the code. The inverse limit is taken over s
1
vote
1answer
52 views

question in latex

\\ command in latex creates a new paragraph. I want a command in which when I finish a line, I want to have next line black and then I want to start from the left of next line. Is there an easy ...
18
votes
7answers
4k views

How to convert mediawiki syntax to latex?

I think I've seen a script for converting mediawiki syntax to Latex. Also, in case there are more than one solution for this, it might be nice to summarize them here.
0
votes
0answers
40 views

Why use \[ … \] and not $$ … $$ for displayed math mode? [duplicate]

For displayed math mode, one can use either one of : \[ ... \], or $$ ... $$, or even \begin{displaymath} ... \end{displaymath} But I see many people here saying: never use $$ ... $$ for ...
4
votes
1answer
205 views

What is the actual function of “&” in math environment?

First of all, I must and want to say that I really like the idea of this website. It's pretty awesome to have a place like this where you can ask all your questions regarding LaTeX/TeX. :D My ...
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. ...
1
vote
0answers
42 views

Typesetting a context-free grammar [duplicate]

Is there a latex package that can be used to produce a language grammar similar to the following figure? If yes, which package?
169
votes
8answers
12k views

Are \( and \) preferable to dollar signs for math mode?

Along the lines of Why is \[ ... \] preferable to $$?, what reasons are there (if any) to favor \( ... \) over $ ... $?
2
votes
1answer
137 views

Syntax of Using Math Mode: Empty Lines (Beginner Question)

I'm just starting to learn LaTeX. I tried typing \begin{equation*} (sample of different operators and symbols separated with \,) \end{equation*} and I got a whole bunch of errors. It seems LaTeX ...
2
votes
1answer
48 views

How to right-align text in a grammar environment?

Using the grammar environment of the syntax package, I cannot find a way to right-align text in my syntax definition: \documentclass{article} \usepackage{syntax} \begin{document} \begin{grammar} ...
14
votes
2answers
517 views

History of the command \verb

Recently I inherited some LaTeX code for a CV that contained an e-mail address typed with \verb}john.smith@uni.org}. This snippet was in the middle of an multicol environment (so it was within several ...
53
votes
6answers
12k views

Syntax Coloring in LaTeX

Is there any way to include Python code in a LaTeX file and automatically color its syntax? Is it possible to do syntax coloring with any other language? If yes what packages can I use to do that?
2
votes
1answer
113 views

TikZ/PGF number in shape name

I'm currently creating my own shapes in TikZ. I'm trying to get a multiplexer to work, but I named the shape mux4to1 and one of its anchors D0. Basically, I'm getting a syntax error with the ...
80
votes
2answers
19k views

When to use \par and when \\

What is the difference between \par and \\ and when should I use \par instead of \\?
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: ...
4
votes
1answer
99 views

LESS and SASS source code formatting

I need to add piece of source code in LESS and SASS. Piece of code is divided into two columns. First column is source code in Less and second column in Sass, something like on this page, but without ...
13
votes
1answer
67k 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.
4
votes
1answer
164 views

Macro take argument without wrapping in brackets?

I want to make macro which do not require curly brackets to accepts an argument. Lets invent an example. Say I want a macro which accepts an optional argument f and an argumentx: \dd[f]{x} And ...
5
votes
3answers
153 views

Delimiting-a-macro-with-itself-chain

Reading this question and the answer of @Werner made me think about if it is possible to have chains of self-delimiting macros like \XX abc \XX def \XX xyz or lets say \begin{someenv} \XX abc \XX ...
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: ...
3
votes
2answers
68 views

Quotes within quotes breaking

When a word in single quotes falls at the end of the quotation, LaTeX decides to render it as "' instead of '". For example: ``He said it was `off the hook''' would render: "He said it was 'off the ...
2
votes
1answer
328 views

Problem with umlaut in Texworks

I can't seem to input the syntax for an umlaut. Here is what I write \documentclass[12pt]{article} \setlength\parindent{0pt} \usepackage{amsmath} \numberwithin{equation}{section} ...
4
votes
1answer
249 views

How should I write $x^*^2$

I want to raise the variable $x^* $ to the second power. Is there a standard way to write this? Perhaps by instead of using $x^* $ using some special star operator I am unaware of.
0
votes
0answers
97 views

Undefined Control Sequence in \multido or \pspicture?

I wrote the following very simple program as I'm trying to make an animation using pstricks and multido, but I get "undefined control sequence" on the end pspicture line. Can anyone just tell me ...
17
votes
3answers
15k views

Reference name of description list item in LaTeX

(Repost from Stack Overflow) I'd like to refer to a description list item by name instead of number. To that effect, I've added labels to each item, but when referencing them I only get the name of ...
32
votes
1answer
15k views

\varepsilon vs. \epsilon

I cannot remember anyone writing the letter epsilon in any other way than \varepsilon in any math class; but in LaTeX \epsilon and \varepsilon are different symbols. Do any of you know why there are ...
12
votes
2answers
230 views

Can spaces at the beginning of a line ever cause problems?

To structure my sourcecode, I often use spaces for padding: \newcommand{\st}[1]{% \begin{tabular}{lr} \emph{Student} & \emph{Score}\\ #1 \end{tabular}% } Can this ever cause ...
4
votes
1answer
244 views

Problem with listings package for Python syntax coloring

I am implementing the method I learned here for putting Python code in Latex. Everything works great except that I have problems with comments. Here's the code from the link I mentioned: ...
9
votes
2answers
497 views

A better way to do nested lists

This is how you type set a nested list in LaTeX: \begin{itemize} \item I have a house \begin{itemize} \item It has 4 walls \item a roof, \item two windows, ...
3
votes
2answers
494 views

Using htlatex with tikz-dependency

I am trying to generate an html file from a tex file using htlatex. The htlatex works well with simple tikz pictures, but it has problem with the pictures (trees) drawn with tikz-dependency package. ...
5
votes
5answers
265 views

add (a little bit long) comment on the equal sign?

There are posts here explained how to Add a comment on top of "equal" and "approximate" symbols , the idea is to use \stackrel{text}{=}, however, if the text is a bit long, for ...
6
votes
1answer
100 views

Redefine \middle| to insert space before and after itself

I want to use \middle| inside of brackets like this. \documentclass{article} \begin{document} \begin{equation} \left\{\frac{1}{n} \middle| n>0\right\} \end{equation} \end{document} ...
8
votes
1answer
80 views

weird ifnum with compact syntax [duplicate]

In some packages like tabularx, I find the following syntax in many places {\ifnum0=`}\fi or even \ifnum0=`{\fi} But I can't figure out why this can be useful for? Is ` a register of some kind? ...
1
vote
0answers
22 views

Creating a new variable from two variables, chosing primarily one and only the other if the first is missing [closed]

i am creating a new variable from two old ones in spss, the old ones have a few missing ones. I want the new variable to have the same value as var1, but if var1 has a missing value than the new ...
5
votes
2answers
1k views

A symbol for same order of magnitude in math mode [duplicate]

I want to write in math mode that something is compared to something else. It is, I want to say that both quantities have the same order of magnitude. What symbol should I use? ...