{parsing} is the process of analysing a string of symbols, either in natural or computer language.

learn more… | top users | synonyms

5
votes
1answer
96 views

Is it possible to run a command stored as text in a variable?

I have some complicated expressions with loads of nested commands which are difficult to work with. To solve this I wrote a parser using pgfparser which creates the expressions for me. I can then copy ...
6
votes
4answers
240 views

Simple pre-parser to separate TeX and comments?

I want to write a mathematical paper both with formulas and with program snippets, side by side. However I do not want the programs displayed or documented by TeX, just be able to extract them into a ...
5
votes
2answers
105 views

Simplifying macro for the align* environment for two column equations

The align* environment provides for a two column layout of equations, similar to the eqnarray* environment. \begin{align*} [left side of the first column] &= [first line of the first ...
5
votes
2answers
51 views

Different Behaviors Digesting \csname x\endcsname and Digesting \x (expansion issue)

This question has been significantly EDITED, as I learned more of the problem. If I was good, I would be able to create macros with multiple optional arguments, but not only can't I, but in this ...
2
votes
1answer
95 views

Turn recipes (rezkonv, mealmaster) into LaTeX code

To better organize my recipes I would like to store them in a database instead of having plenty of books being scattered all around. There are many programs to realize this by offering a GUI to either ...
8
votes
0answers
125 views

Parsing question: Do curly braces affect LaTeX compilation time?

I have an old and slow computer and long LaTeX files. When typing I prefer to use \frac 1{x} instead of \frac{1}{x} or x_i instead of x_{i}. Does the presence or omission of curly braces in these ...
4
votes
2answers
52 views

Parsing file name into document

I have a group of tex files named according to the following convention: xxx_yyy_zzz.tex I would like to use the components (xxx, yyy, zzz) of the file name as inputs in the document, n particular ...
11
votes
1answer
103 views

Parsing commands with multiple optional arguments

Some LaTeX commands accept multiple optional arguments. Here are some examples: \makebox[<width>][<pos>]{<text>} \framebox[<width>][<pos>]{<text>} ...
4
votes
1answer
132 views

Plain TeX macro to read a document in Pig Latin

Say I have a file eng.tex: \def\encounter (#1){Hello, #1!} \encounter (World) \bye I convert it to Pig Latin and save it as pig.tex: \efday\encounterway (#1){Ellohay, #1!} \encounterway (Orldway) ...
2
votes
0answers
57 views

How to maintain data to be both implemented and documented (in a personal package)

I'm looking for the best strategy for maintaining, in a personal package, a (long) list of data that has to be defined in the implementation and to be documented in the documentation. Let me be more ...
12
votes
5answers
384 views

Parsing hexadecimal numbers to binary and iterating over bits

I'm currently working on a software for an graphic display, so I recreated it in TikZ for documentation purposes: I currently use this to set individual pixels on the display: \setpixel{x}{y} ...
21
votes
5answers
377 views

How to define a command that surronds an argument with parenthesis if it contains a comma?

I have a very simple command in which one of the arguments can contain commas, in which case the output may not be easily readable since the text in which it is used may contain other commas, making ...
5
votes
2answers
182 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 ...
4
votes
2answers
103 views

Parsing rows (`\\`) and tab characters (`&`)

I have a use for parsing what would look like tabular input data, except that it isn't part of a tabular environment, but rather the argument to a macro. So I developed two macros, \readTABrow which ...
5
votes
1answer
64 views

Processing a particular line of text in a document

My question points actually to a particular problem, as opposed to the more general type of problem suggested in the title -- which would nevertheless be interesting to me to see answered: I'd like to ...
12
votes
3answers
264 views

How could LaTeX replace the tokens <= by the command \leq?

How could LaTeX replace the tokens <= by the command \leq efficiently? Example 1: I have this code: \[ 2x <= 4x - 2 \] And I want to get after the compilation this: Example 2: \[ ...
13
votes
5answers
1k views

How do I write a macro having comma-separated and variable number of arguments?

I want to write a macro in LaTeX2e that can pass \textcolor, which is embedded in another macro, the values of the colour model gray, rgb, or cmyk. The number of arguments specified implies the colour ...
13
votes
1answer
146 views

What is considered a token for non-standard input encodings?

When I use an input encoding to (La)TeX that allows me to directly input characters such as é and ä (such as by declaring \usepackage[utf8]{inputenc}), how is a token defined? Specifically, is it ...
5
votes
1answer
486 views

How does 'filecontents' keep LaTeX parsing while temporarily stop writing output

We all know filecontents.sty can do \documentcalss{article} \usepackage{filecontents} \begin{document} Hello World \begin{filecontents}{dummy.txt} No one will read this if I don't use it ...
10
votes
1answer
82 views

Scan argument for parentheses

I'd like to define a macro which expands to (#1) if #1 does not contain any parentheses, but expands to \big(#1\big) if it does. I'd choose simplicity over generality: if a solution works in the most ...
13
votes
4answers
841 views

Drawing Young tabloids

I would like LaTeX to produce output like the following (without the 2 a so called Young tabloid), ideally by writing \ytabloidshort{123,56} (using one character per cell, ideally allowing ...
18
votes
3answers
326 views

What are the effects of an empty group, {}?

In order to have a syntactic space after a no-argument command, one is taught to delimit the command token with an empty group ({}), like this: \somecommand{} more LaTeX material. However an empty ...
3
votes
2answers
1k views

In the siunitx package, how do i get it to produce uncertainties with the \pm symbol instead of parenthesis

Using the siunitx package, if I specify an error with the \pm symbol then it automatically converts it to a form using parenthesis. I would like it to not do this and keep the \pm symbol, but still ...
2
votes
1answer
123 views

How to check if token is a macro?

I am thinking about possibility to parse LaTeX document. What I really need is to track category codes of symbols. As I understand TeX expands all of macros in his mouth and tracks changes of category ...
3
votes
2answers
293 views

Shell script which parses .tex files for figures

I would like to pull all figures including captions out of multiple .tex files and write them into a single new .tex file. This means I have to parse for \begin{figure} . . . \end{figure} and ...
8
votes
2answers
85 views

Parsing various types of page ranges with a single command

Having to treat a considerable amount of page ranges, I'd like to have a robust and simple command that would parse and print them correctly. The most simple case is e.g. 264,15-26 which ...
2
votes
2answers
571 views

How to automatically insert values into latex code/template

I'm in the process of generating an automated report in pdf from latex. Each report is the same, but has different values/graphs. The graphs is no problem, but what is the best way to process a latex ...
44
votes
4answers
3k views

Is there a BNF grammar of the TeX language?

I'm looking for a BNF grammar of the TeX language, does it exist?
5
votes
2answers
145 views

Parsing leading hardspaces

This question is related to (but distinct from) this question: Parsing a \$ as part of an improved \getargs command, which I asked earlier. I am experiencing a residual space in a string result from ...
7
votes
4answers
185 views

How to break a line after the n-th word?

Suppose i have a raw text defined as: \newcommand{\rawtext}{this is some raw text with many words in it} How to break this line after a given word or position? Of course, i only have access to ...
-11
votes
2answers
971 views

Stringified commands to macros sequence

First, what is the proper terminology for a "string" in TeX/LaTeX that is an argument for a macro? e.g., \macro{somestring} Obviously somestring is a token, set of tokens, string, argument, etc. I ...
6
votes
1answer
108 views

Parsing a \$ as part of an improved \getargs command

As the author of stringstrings, I am acutely aware of its slowness. For small tasks, that slowness can be annoying. For larger tasks, it can be prohibitive. Recently, in using data column as ...
1
vote
0answers
99 views

Help with verbatim-like environments [closed]

I am writing a script for LaTeX shallow parsing (assuming that there are no complicated definitions in the preamble). First of all I decided to check the document for in-line verbatims and comments, ...
8
votes
1answer
243 views

Replacing Leading Minus Signs in Environment

In this question concerning negative signs and the alignment of entries in matrix environments, Heiko Oberdiek gave a great answer in which he uses a user-defined command called \matminus instead of ...
9
votes
5answers
295 views

Parse dotted string, extracting last part

I want a macro that will separate a string like "1.2.3" into two parts: the part until the last dot (call that the context) and the last number. This seems a pretty basic application of a helper ...
10
votes
2answers
277 views

The different meanings of LaTeX's \stop command

we know that \stop will cause LaTeX to stop parsing and output what it has processed up to this command. But then I discovered another way to use it, as demonstrated in this minimum working ...
1
vote
1answer
165 views

Using \SplitArgument with r() arguments in xparse

I have been experimenting with using the xparse package for custom document macros with a Markdown-like syntax. For example, I used to write \cut{x}{P}{Q} to produce . With the help of xparse, I ...
6
votes
1answer
162 views

Arbitrary text parsing from a separate file

I'm still very new to the world of TeX, so please bear with me if this question is unclear or has been asked before. I'm starting to figure my way through TeX and the millions of plugins and ...
3
votes
2answers
230 views

How to stop a block of code from being parsed?

I would like to pass some latex code to lua directly without it being parsed: \directlua{ PrintPrettyLatexCode("LATEX CODE GOES HERE!") } BUT latex tries to parse the "LATEX CODE GOES HERE!". I ...
10
votes
1answer
411 views

Extract the logically first slide in a Beamer overlay specification?

When writing Beamer slides for a talk, I find that I often want to have some text (usually math) visible on a group of slides and be alerted on only the first slide in the group. For example, I can ...
9
votes
3answers
310 views

Implementing car and cdr in TeX

I've been trying to implement a macro that reads and transforms its argument into a different form...but I'm having quite a bit of trouble finding or creating even the most basic parsing tools. Case ...
3
votes
1answer
107 views

pgfparser module and blank spaces

After the question Macro for a code translator, I followed the advice of polgab and used the pgf parser module. I was very disappointed when I reached the point of trying to parse a blank space. I ...
6
votes
3answers
141 views

String parsing macro fails within custom cite command of biblatex?

I am trying to use the same string parsing macro as in String parsing macro fails within a minipage environment?; but this time in context of biblatex - and I'm having similar problems, I guess. ...
4
votes
1answer
395 views

String parsing macro fails within a minipage environment? [closed]

I am trying to work with a string parsing macro, found in the answer of TeX capacity exceeded while parsing a date string - TeX - LaTeX. Basically, I have strings num01, num02... num09 - from these, ...
6
votes
1answer
127 views

Is it possible to scan until the end of the current `\item`

I do a lot of itemize lists in beamer presentation which, in a later step, I want to format nicely, for instance, typeset everything up to the first colon in boldface and the remaining part scriptsize ...
4
votes
1answer
171 views

Parse a file with a regexp and return first match

I need to write a command that searches a file for a string that matches a certain regexp, and inserts that string. I know how to parse a string of text using a regex with \usepackage{l3regex} ...
5
votes
3answers
524 views

How to extract parts of (La)TeX document?

I want to run queries against LaTeX documents like these: get list of all equations, even if one declares \def\be{\begin{equation}} and uses it; get list of all arguments of some command (e. g. ...
7
votes
4answers
338 views

Read command with varying input arguments

Out of curiosity I'd like to define a LaTeX command that looks like: \newcommand{\trigger}{out1,out2,...,outn} with a rather strange function (at least, I couldn't find anything like this ...
-1
votes
1answer
161 views

LPeg alternative match? [closed]

Looking over the LPeg docs I do not see a way to have alternatives(OR) http://www.inf.puc-rio.br/~roberto/lpeg e.g., a | b will match a or b. Am I missing something?
6
votes
4answers
393 views

List parsing with special input/optional arguments

I’d like to parse a list where the elements can be given as either [<pre>]<text>[<post>], where <pre> and <post> are optional, or (<special text>). I found a ...