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

learn more… | top users | synonyms

4
votes
1answer
439 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
131 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
189 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
558 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. ...
8
votes
4answers
350 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
166 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?
-14
votes
2answers
1k views

Stringified commands to macros sequence [closed]

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
4answers
590 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 ...
6
votes
4answers
418 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 ...
16
votes
5answers
467 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 ...
2
votes
1answer
112 views

Parsing some buzzwords in the Latex document and replacing them by link possible?

Is it possible to parse teh whole document automatically, looking for buzzwords, which I will maintain in a special list, and replacing the buzzwords by links to a predefined page e.g. a glossary?
5
votes
1answer
172 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... ...
3
votes
2answers
453 views

Split long string into paragraphs

How can I test a string to see if it has more than one paragraph, and split a string that contains multiple paragraphs into two strings, one with the first paragraph of the original, one with the ...
3
votes
2answers
2k 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 ...
5
votes
1answer
764 views

Generate a parse tree for TeX

If I google for parse tree and TeX. All I'm getting are how to draw parse trees in TeX. I want to know if there are programs that can parse TeX, and output a parse tree that's easy to manipulate.
5
votes
3answers
220 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.: ...
2
votes
2answers
330 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} ...
7
votes
2answers
477 views

Formatting crystallographic indices

I would like to make a command in LaTeX that can be used like this: \zoneaxis{1 2 -3} \zoneaxis{2 -1 -1 10} and would produce this: $[1\,2\,\overline{3}]$ $[2\,\overline{1}\,\overline{1}\,10]$ ...
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
2answers
862 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 ...
9
votes
2answers
668 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 ...
7
votes
2answers
1k 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 ...
11
votes
1answer
5k 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 ...
5
votes
4answers
1k views

LaTeX parser to perform operations on tags (commands) and its content?

Is there a LaTeX parser available that can be run from a (*nix) command line, and that allows operations on LaTeX tags/commands and its content? What I am trying to do is, for example: script-wise ...
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? ...
47
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?
13
votes
5answers
924 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, ...
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 ...