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

learn more… | top users | synonyms

11
votes
1answer
44k 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
90 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
128 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 ...
77
votes
4answers
2k 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
48 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
35 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
244 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
39 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 ...
16
votes
3answers
12k 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 ...
29
votes
1answer
9k 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 ...
10
votes
2answers
194 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 ...
3
votes
1answer
69 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
393 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
304 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
188 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 ...
5
votes
1answer
78 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
70 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
478 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? ...
14
votes
2answers
606 views

What is the difference between square brackets and curly brackets in a command invocation?

Pardon the naive beginner question. In a command like: \textcolor[HTML]{4C7045}{dark green text}, or \documentclass[12pt]{article}, or \begin{figure}[htb], why are some arguments surrounded by [] and ...
5
votes
3answers
237 views

Why is TeX/LaTeX-“programming” so different from other languages in terms of syntax?

Usually, e.g., when I want to have an if, I do something like this: if(value) { ... whatever code ... } But in LaTeX, its: \ifnum\count0<100 ... whatever LaTeX-code ... \fi There are ...
1
vote
1answer
54 views

numbers in BibTeX entries: syntax highlighting vs. reality

The following example has one relevant entry for this question, the year field. @INPROCEEDINGS{1181437, author={de Oliveira, W.R. and De Souto, M. C P and Ludermir, T.B.}, booktitle={Neural ...
1
vote
0answers
64 views

ASCII characters used in plaintext representation of TeX [closed]

I'm writing a parser/transformer thingie that accepts valid LaTeX, and emits valid LaTeX. Is there a list of ASCII characters that are allowed in TeX math mode? Or is any character fair game? ...
4
votes
1answer
135 views

How can I highlight SPSS Syntax code with the listings package?

I'm writing my master thesis at the moment and I want to add some code listings to the appendix. The code is written in "Syntax", the programming language of SPSS Statistics. Is there a way to ...
17
votes
7answers
3k 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.
15
votes
2answers
459 views

Why does `x_\text y` work?

As far as I have understand the tokenization in LaTeX, x_\text y will be split up into x _ \text y Now the _ will consume/bind to the next token. However, \text takes an argument as well. If _ ...
4
votes
0answers
51 views

Why `\\` is wrong here? [duplicate]

The following codes return errors \documentclass{article} \begin{document} cd\\ [asd] \end{document} But this one will work \documentclass{article} \begin{document} cd [asd] \end{document}
3
votes
1answer
422 views

Help with custom syntax highlighting for TeXworks

I recently learned of the option to make a custom syntax highlighting system for texworks as laid out in the texworks manual If you go to the *\customizing texworks\syntax highlighting*section of the ...
26
votes
7answers
2k views

What's a good editor for (La)TeX programming?

I've found several questions about editors for writing LaTeX documents ( LaTeX Editors/IDEs seems to be the definitive one). But I'd like to know which editors are out there that help you develop ...
1
vote
1answer
50 views

Remove spaces from source code

I have this code (javascript from language option supported in listings) \lstset{language=javascript} \begin{lstlisting} $('#term').terminal(function(command, terminal) { var cmd = ...
44
votes
5answers
47k 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 ...
1
vote
0answers
122 views

Kile syntax highlighting: A single dollar sign in the preamble

I'm using Kile to edit my LaTeX documents. I define my own custom environment to hightlight LaTeX code named lstLaTeX with the following code: \documentclass[a4paper]{scrartcl} ...
2
votes
1answer
256 views

After changing Kate's LaTeX syntax highlighting file, syntax highlighting for LaTeX can not be selected anymore in Kile

I wanted to adapt the Kate LaTeX Syntax Highlighting file (in my case: /usr/share/kde4/apps/katepart/syntax/latex.xml), to have a different highlighting in Kile, as in the answer to disable syntax ...
4
votes
1answer
124 views

In forest (tikz) for syntax trees, how do I create an arc above one node separating it off from the rest of the tree?

Here's a picture example of what I want: I'm able to make the type of arc that I want with this command: \draw (-2,-2) [black,thick,dashed,domain=45:180] plot ({cos(\x)}, {sin(\x)}) ; But it ...
2
votes
1answer
165 views

A very basic TikZ code that is not working

I tried to type a TikZ code for the first time but it did not compile, and I have no idea why. Is there any other packages that I have to use or is there anything wrong with the syntax? ...
230
votes
8answers
18k 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 ...
7
votes
2answers
5k 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 ...
3
votes
3answers
339 views

Make an exam format with a logo

I am trying to make a header of an exam page but with logo. Below is my code. \usepackage{graphicx} \begin{document} \firstpageheadrule \begin{figure}[] \includegraphics[width=20mm]{logo.png} ...
20
votes
2answers
10k 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, ...
4
votes
2answers
140 views

Problems Using AVM package for LFG structures

I am trying to draw LFG f-structure matrices using the avm package (https://www.essex.ac.uk/linguistics/external/clmt/latex4ling/avms/). For some reason my avm objects do not respect the \\ command, ...
2
votes
1answer
139 views

What comand should I use to fork used in math [duplicate]

When doing practical math, you often fork your calculation due to some conditions, eg. when doing equations with absolute value. There is a symbol for this, and I wonder if mathJax can render this one ...
3
votes
0answers
169 views

How do you read LaTeX syntax

Coming from the programming language side, I am used to the very regular syntax of these languages. E.g. in Python a function call has to be like below: callfun(arg1,arg2,key1=val1,key2,val=2) This ...
25
votes
2answers
631 views

The rhyme and reason of function argument syntax (brackets versus braces)

I'd like to gain some intuition as to the choices of brackets versus braces in function arguments. As in [...yadda...] versus {...yadda...}. I'm a long-time user of LaTeX but am poorly educated as to ...
4
votes
1answer
218 views

Add keys to table (with picture and code) [duplicate]

As you see in the red part of the picture, I would like to add keys to explain what the brackets stand for. I just added this with paint, but is there a way to do this in tex? Also, are there nicer ...
23
votes
2answers
527 views

Backward definition of (La)TeX commands

Again and again I see, that TeXnicians define commands and do several things with them in the reverse order, I would do this as amateur. See this example: In his answer to scrpage2: Three ...
0
votes
0answers
56 views

CAS Syntax in LaTeX

Good evening, I am creating a LaTeX file that is a Lab for Maple. I would really like to have the CAS syntax in My LaTeX file. Meaning is there a way I can have LaTeX x^2 without wanting to make ...
2
votes
1answer
92 views

Label on grammar enviroment

I want to have a caption and label on my grammar environment, and have implemented the solution here: How to use caption and label in grammar environment? got my grammar displayed with a caption and a ...
13
votes
1answer
154 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 ...
3
votes
1answer
164 views

Why is my cross reference not working and some other questions

I am a TEX beginner and I am now learning how to create a reference. I am reading the book "The Not So Short Introduction to LATEX2" by Oetiker, Partl, Hyna, Schlegl; on page 42 section 2.8 Cross ...
7
votes
1answer
326 views

Clear and readable syntax style for tikz trees with edge labels and options

I'm fairly new to tikz and TeX but I don't have a problem writing the code for the tree. I just would like to have a human readable tree. Here's a minimal expample of the tree without edge labels or ...