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

learn more… | top users | synonyms

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?
11
votes
1answer
4k views

pgfplot: Datafile format for datetime field

I have a datafile (which I may manipulate to any format), it contains a date-time stamp currently in the form "year-month-day hour:min" and a single variable for each recorded time. When I attempt to ...
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 ...
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 ...
12
votes
2answers
798 views

Parsing files through LuaTeX

This question has two parts: How would one generally parse a file with LuaTeX, assuming the file only holds data that is delimited either by spaces, commas or semicolons. How would you parse the ...
7
votes
2answers
941 views

Iterate over space-separated list

I’ll briefly explain the background in case this can be solved simpler but I’d still be interested in an answer to the actual question, too. My chapter titles are very narrow and use a large font so ...
13
votes
5answers
863 views

Parse comma-separated list of command names with spaces

Problem This question is related to How can I specify a long list of math operators? – but with a twist: I want to allow spaces in in the comma-separated list, like so: \newacronyms{acm, ams, cpu, ...
-11
votes
2answers
972 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
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 ...
16
votes
5answers
455 views

Applying an operation only to capitals

I'd like to apply a function to capitals only so that: \emphcaps{YaWeH} Outputs like: \emph{Y}a\emph{W}e\emph{H} Preferably without using too many packages (I already use memoir). NOTES: I use ...
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 ...
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} ...
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: \[ ...
9
votes
2answers
643 views

\def taking next word as argument?

This question is a variant of my previous question requesting a macro that takes the rest of the line as argument. I would like to write a macro that would take the next word as argument, where word ...
8
votes
2answers
2k views

What parsers for (La)TeX mathematics exist outside of the TeX engines?

Inspired by the author's motivation for asking Is there a BNF grammar of tex language. Are there any well done libraries that can parse some subset of TeX mathematics independently of the TeX engine? ...
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 ...
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 ...
5
votes
1answer
165 views

How to skip an `\item` entirely, with no side-effects?

In Ryan Reich's great answer to my question on onlyitems, he had LaTeX ignore an \item by setting it into a box and then not using the box, effectively discarding it: ...SNIP... ...
2
votes
2answers
310 views

Time calculation for task reports

Consider this MWE: \documentclass{article} \newenvironment{dayreport}{\begin{tabular}{ll}\hline Task & Time\\\hline}{\hline\end{tabular}} \newcommand{\task}[2]{#1 & #2\\} \begin{document} ...
16
votes
4answers
2k views

Syntax of TeX/LaTeX

{} and [] do some kind of grouping, and comma seems to be special as well. Being a programmer I find it frustrating to use Latex on incantation-only basis. I would like to know how does it exactly ...
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 ...
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. ...
6
votes
4answers
522 views

Parse a string into tokens of numbers and not numbers

I have a string that I want to parse into to numbers and non-numbers. For my purposes: A Number can EITHER be any sequential string of digits OR sequential string of digits with a . followed by ...
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 ...
5
votes
3answers
210 views

Cartesian product of two lists as parameters for a command

Friends, I used to suffer a lot when had to iterate through elements of a list, but thanks to egreg's suggestion, I've been successfully using the etoolbox package for that task, e.g.: ...
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 ...
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, ...
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 ...