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

learn more… | top users | synonyms

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 ...
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 ...
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, ...
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 ...
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}
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 = ...
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 ...
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} ...
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. ...
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
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? ...
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 ...
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 ...
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 ...
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 ...
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 ...
0
votes
0answers
33 views

How do you format a Dates Contraction in LaTex? [duplicate]

I'm writing a paper and I need to include a date, for example 20th January 2011. How can I make the Contraction smaller and position it correctly as an ascender/superscript?
3
votes
1answer
142 views

Applying Matrix Operation Code

I'm (relatively) new to LaTeX, and I'm having a syntactic problem using the wonderful code here, which allows arbitrary matrix operations in LaTeX. I wrote a macro to generate certain matrices. ...
2
votes
1answer
57 views

Short syntax for including multiple times the same pages in pdfpages

Using the pdfpages package I can do something like this to merge some pages of a document. \includepdf[page={1,1,1,2,2,10,10,10,10},nup=1x2]{mypdf.pdf} In this case 3 times pages 1 and 2 times ...
1
vote
0answers
61 views

Dialect of the `[1.]` suffix in `\begin{enumerate}[1.]`?

I have a tool (pandoc) that is producing tex. Among the output is the following: \begin{enumerate}[1.] \item foo \item bar \item baz \end{enumerate} pdflatex then refuses to compile it with error ...
5
votes
0answers
121 views

“Standardizing” LaTeX code? [duplicate]

Is there a program for LaTeX code akin to HTML Tidy that "standardizes" or "canonically" formats (automatically indents, spaces, etc.) LaTeX code? AucTex formats code, but it doesn't appear to create ...
3
votes
1answer
137 views

How to change font-size for a grammar declaration

I have a grammar declaration like this: \documentclass[12pt,a4paper]{report} \usepackage{syntax} \begin{document} ... \begin{figure}[h!] \begin{grammar} <A> ::= `<--' ...
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 ...
5
votes
2answers
193 views

Why various syntaxes for various commands?

I understand that the standard syntax of commands in TeX is \name[optional-1]…[optional-n]{argument-1}…{argument-n} The tabular environment, however, apparently takes its optional arguments after ...
1
vote
1answer
178 views

Syntax highlighting for SPARQL query in a listing? (works fine in minted environment but not in listing with mint)

I can do syntax highlighting in the minted environment, for any SPARQL query using this Pygments lexer thanks to this answer. My problem is how to get SPARQL syntax highlighting to work with mint in ...
7
votes
1answer
336 views

Change how to enter a matrix in Latex

In Matlab I can create a matrix by typing A = [1 2 3; 4 5 6; 7 8 9], for this the space is a delimiter between the entries of the matrix. I am wondering if there is a package which makes it possible ...
6
votes
1answer
105 views

Commands with Capital letters in their name

A topic that appear over and over is to explain the difference about commands such as \operatorname vs. \DeclareMathOperator. So far I've seen discussions about using one or the other, but no one ...
5
votes
1answer
168 views

Relational Grammar arcs

I'm quite used to draw syntactic trees and even AVMs for different linguistic theories, but I've stumbled upon the need to draw Relational Grammar / Arc-paired grammar arcs for a paper I'm writing ...
2
votes
1answer
51 views

Changing Format of Table Entries

I had attempted to shorten this table and I think I don't think I've edited it properly. In particular I think that I've made a mistake changing everything up to the numeric entries. Would anyone ...