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

learn more… | top users | synonyms

0
votes
0answers
31 views

Problem with microtype's `\textls` and math mode

I have some issues with classicthesis' \spacedlowsmallcaps command that I could bring down to the following MWE: \documentclass{scrartcl} \usepackage{microtype} ...
1
vote
0answers
32 views

Raw typesetting output

I would like to invoke tex from an external program (python) and receive the output as a sequence of (glyph id or unicode (whatever tex uses), x, y, width, height) to render it myself. Is there some ...
4
votes
3answers
409 views

Defining \tg so it behaves exactly like \sin and \cos?

In my country, instead of tan, we use tg (this is just one of them). I want to be able to type \tg{x} and possibly \tgx So that Latex recognizes them. I tried defining them like this: ...
3
votes
1answer
42 views

Creating a command that concatenates an input string token by token

Using (first of all) xparse I want to create a command like this: \DeclareDocumentCommand{\c}{ s > { \SplitList { ; } } r""} { % do something } It basically should just do the following: ...
1
vote
0answers
64 views

Why doesn't TeXstudio suggest any bib items for citation (can't read multiline arguments)?

When i use the \cite{} command, TeXstudio doesn't find any bib items. Normaly i would expect that after typing \cite{ TeXstudio would suggest me all bib items aviable but it doesn't suggest me any. ...
3
votes
1answer
69 views

How to properly parse […]{…} with expl3?

What would be the more efficient way of parsing [...]{...} with expl3, that is to get the content inside the brackets in one variable and the content inside the braces in another one? This question ...
4
votes
2answers
70 views

Generalized File Name Parsing

In Parse filename and extract revision from name, the OP wanted to parse a file name of the format cv3.01 to extract the revision number 3.01. @egreg posted the following solution for a file name ...
7
votes
2answers
103 views

Parse filename and extract revision from name

My file is named 'cv3.01.tex'. I want to extract the '3.01' part and use it in the footer of the document, i.e. 'Rev 3.01'. I found Parsing file name into document, but it does not work for my ...
1
vote
1answer
36 views

Parse Argument by Character while Executing Embedded Macros

I am interesting in parsing a string of input character by character, and doing something to each character. In this MWE, I merely apply a \textbf to each successive character as an example, to ...
4
votes
1answer
83 views

Is there a parser of classic LaTeX/ConTeXt syntax?

Every time a question about parsing tex syntaxes come up, the first answer is: it's not possible and here is an (convuluted) example why. So I'm trying to narrow the scope of the question to what I ...
6
votes
3answers
107 views

Extract all arguments of a certain command from a document

I have a command \foo which takes two arguments and which I use about a hundred times throughout my document (but never within an argument of another instance of \foo). I now want to spellcheck every ...
3
votes
2answers
63 views

Formatting Strings in Dynamic Variables with xstring

I need to format a string resulting from a dynamic variable set in a separate program for a LaTeX generated report. In particular, if a variable has a negative value (starts with a minus sign), I ...
3
votes
1answer
70 views

List separated by semicolons, ending with a period

I am using a university-developed document class for my thesis. This class has the command \keywords which takes a list of \key commands and this is printed out as a keyword list after the abstract. ...
1
vote
1answer
59 views

Next word macro inside braces

I have defined a macro that highlights the next word using \def!##1 {\hkw{##1} }% where in this scope, ! is an active character. So it works fine to write. \emph{This is a !good example} but not ...
0
votes
1answer
78 views

new \input{file} Package, Command wrapper: microtype .tex with reserved symbols

I know enough LaTeX to produce great looking documents. LaTeX makes it more difficult to NOT do that. But I don't advanced LaTeX or TeX or plainTeX or "@" or other advanced, cryptic programming ...
3
votes
1answer
118 views

Is there a formal grammar for *Equations* in TeX/LaTeX?

I've looked at this and this and understand there is no grammar of TeX as a whole. I am wondering if there is a grammar just for equations. They are relatively easy to identify in an amsmath file ...
4
votes
1answer
143 views

In LaTeX, what is the most efficient way to search for an optional token in given input?

My question is inspired by this comment by Joseph Wright. Let's say we have input strings with varying character combinations, such as: ...
2
votes
2answers
155 views

Translate sage input to latex without simplifying

In sage it doesn't seem possible to print latex code of an expression without simplifying it in some way. For example \sage(x/x) should translate to \frac{x}{x} instead of 1, see this question on ...
6
votes
3answers
333 views

Parse argument with a number and an optional letter

How to define a macro which takes a string made by number and an optional letter and then branches on the basis on the letter? Since this is an extension of an existing package, it is preferable not ...
4
votes
4answers
122 views

Recursive String Parsing

I have been working on writing a recursive stream processor in latex that converts a shorthand version of a set of highly used commands into a much longer form. The code below represents what I had ...
4
votes
1answer
61 views

List Parsing the ascii space character

I have been using the list parsing functionality from etoolbox and I have a weird use case in which I want a space separated list. \usepackage{etoolbox} ...
1
vote
1answer
115 views

Is there a BNF-grammar for simple constructs of the TeX language?

(Previously) Is there a TeX grammar that parses simple constructs like document, enumerate, section, subsection, etc.? I'm not interested in parsing complicated constructs requiring a more complex ...
7
votes
2answers
200 views

Parse command argument separated by comma

I want to mix several language in my document, and the output language can be chosen according to corresponding variable I want to define this kind of command \mulan[en,fr,ru]{arg1}{arg2}{arg3} to ...
13
votes
3answers
2k views

Ways to parse JSON in LaTeX?

I'm writing my recipes (food) in a small textfile in JSON. Are there any ways to parse this in LaTeX? I know, that are lots of templates dealing with recipes, but I want to have my own style, which ...
11
votes
3answers
459 views

Parser for decimal numbers in (plain) TeX

I need help writing a parser for decimal numbers using only TeX and plain TeX. The set of accepted inputs is given by the regular expression: (+-)?(0-9)*(.,)?(0-9)+ The parser need not do anything ...
9
votes
3answers
240 views

How to parse multiple arguments in TeX macros

I have dates formatted {yyyy-mm-dd}. I would like display the time elapsed between the dates in the form Y years, M months. Given the format of the dates, it seems easier to use arithmetic than to ...
17
votes
4answers
1k views

Bash lstlistings treats “$#” as a comment

Background: In Bash, $# represents the number of arguments, and # starts a comment. Consider the following Bash script: # This is a comment while [[ $# -gt 0 ]]; do echo $1 shift done Note ...
3
votes
0answers
297 views

Automatic dropcaps for the first letter of a chapter

I'm in the process of writing a LaTeX style for thesis dissertations, and would like to automatically transform the first word of a chapter to dropcaps. This is trivial to do manually using the ...
1
vote
3answers
138 views

Parse csv-list, function with >1 parameters as callback

In my texts I have to deal with lists, whose items need to be formatted seperatly, i.e.: \funktion[3][]{T}--\funktion{S}--\funktion[3][7]{D}--\funktion{T} In \funktion which leads to \emphsubsup the ...
4
votes
2answers
115 views

Add content from an external file to the input tokens for parsing

I have a possibly very long sequence of tokens which is parsed by a macro. I would like to be able to read parts of this sequence from external files, if this is possible. I made up an MWE for this ...
2
votes
0answers
96 views

Generating LaTeX reports from XML *without* external scripts

First of all, I apologize if this is pretty similiar in nature to my previous question: Reading and (custom) formatting a CSV (not \csvautotabular) I thought it would be better to separate the two ...
0
votes
1answer
104 views

Automatic parsing/extraction of single-argument commands from input (for use in new environment)?

I'm not sure whether this is in principle possible, so let me try to explain; consider this MWE: \documentclass{article} \usepackage[showframe]{geometry} \usepackage{tikz} \usetikzlibrary{calc} ...
5
votes
1answer
496 views

Using tikz diagrams in beamer with minor differences between slides

I'd like to highlight different parts of a tikz diagram in beamer slides using something like the \only command. I was able to do this at the level of nodes, which is probably fine, but as I have some ...
16
votes
2answers
994 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 ...
6
votes
2answers
168 views

Arguments to function not losing braces

This MWE is boiled down so much the usefulness of the code is lost. However, the code nevertheless still exhibits the problem I'm encountering. \documentclass{article} \usepackage{pgffor} ...
1
vote
0answers
105 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
2answers
350 views

Parsing and programming in TikZ

Background: I'be been reading the PGF manual (keys section) and today the TeX Book just arrived in the mail and just started reading chapter 7 (How TeX reads what you type) -- feeling like Mickey ...
7
votes
4answers
487 views

Only get filename and extension of listing, not whole path

I am trying to add the file name as caption. I was able to do this setting caption=\lstname but this shows the full path. I am now trying to get the name of the file and extension to show only. I ...
1
vote
0answers
16 views

Using \filename@parse gives error [duplicate]

I am trying to use the \filename@parse like this: \filename@parse{\lstname} but I get this error: ! Undefined control sequence. l.22 \filename @parse{\lstname} ? Am I missing some ...
4
votes
0answers
128 views

PGF pretty number printing equivalent in LaTeX

For TikZ and pgfplots I use : \tikzset{/pgf/number format/.cd,use comma,1000 sep={\,}} And all numbers are typeset accordingly, with no other command. Is there a way to have the same convenience ...
1
vote
0answers
61 views

Is LaTeX a context-free grammar? [duplicate]

How can you tell if something is a CFG or not? I am wondering if you could create a math/LaTeX parser using a parsing expression grammar (PEG), or not. Is this possible, and how can you tell?
5
votes
1answer
155 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
337 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 ...
6
votes
2answers
205 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 ...
6
votes
2answers
90 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
273 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 ...
13
votes
1answer
268 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
300 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
273 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
189 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) ...