Questions tagged [parsing]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
23 views

lstlisting: Unexpected newline/missing background color after trailing space in escape section

I'll start with a minimum failing example: \documentclass{article} \usepackage{listings} \usepackage{color} \lstdefinelanguage{x}{ escapechar={!} } \lstset{language=x, breaklines=true, ...
0
votes
1answer
38 views

Parsing issues with resume written in LaTeX

I've written my resume in Overleaf and downloaded it as a PDF to submit to job applications. For some job applications it works but for others I'm told there is a parsing error (i.e. their automated ...
5
votes
1answer
100 views

Automatic text highlighting based on a dictionary

I would like to automatically highlight parts of a running text, based on whether the word is in a predefined dictionary, or not. Something along the lines of... \documentclass{article} \mydictionary{...
0
votes
2answers
66 views

Weird 'ProvidesPackage' vs 'newenvironment' macro expansion

currently improving an existing package ('ditaa', based on ditaa0_9.jar) to add support for svg (implemented in ditaa-0.11.0-standalone.jar) yet I'm facing strange macro definition/expansion. ...
0
votes
0answers
86 views

Is there a specification of the BibTeX log (.blg) file format?

TeX IDEs may be interested in parsing not only LaTeX .log files, but also BibTeX .blg files, see for example https://github.com/James-Yu/LaTeX-Workshop/issues/2324. Is there a file format ...
4
votes
1answer
486 views

is there a python module for parsing LaTeX?

I am looking to write python programs that modify LaTeX source files. To do this I would like to have a basic parser in python that can reliably read and write LaTeX files while maintaining the tree. ...
1
vote
0answers
44 views

Macro to change the extension of filename

I would like to have a macro to change the extension of a file name. For example, my macro needs to take an argument like Figures/Fig.xxx and return me Figures/Fig0.yyy. I found a solution in Extract ...
3
votes
2answers
65 views

Convert \input to number

I'm reading several txt-files from disk and I want to do some simple calculations on them and be able to print them on the page. Basically I have: \newcommand\getinput[2]{ \immediate\write18{do-...
6
votes
4answers
381 views

What LaTeX macros cannot accept a group as an argument?

I am working on a LaTeX pretty printer that parses a LaTeX document and then re-renders the source. (I know that this is not possible in all cases, but it should be possible a lot of the time.) In ...
0
votes
0answers
26 views

Automatically elaborate an external table's data

I have to create a serie of sheets with LaTeX using informations from a LibreOffice table (but I can convert it in other formats if needed). The problem is, the table is some hundreds rows long, so it ...
6
votes
1answer
178 views

Why does LaTeX parse square brackets differently than curly braces?

In this comment (copied below without effort to preserve formatting): It may be worth pointing out why this happens. The [ and ] bracketing of optional arguments in LaTeX isn't as robust as the { .....
2
votes
1answer
152 views

How to escape “and” as list delimiter in bibtex/biblatex?

In my BibLaTeX manual, it says: Literal lists are parsed and split up into the individual items at the and delimiter but not dissected further. Literal lists may be truncated in the bib file with ...
3
votes
3answers
118 views

Parse sentence and split into parts

I would like to generate titles for my documents that look like this: \documentclass{article} \usepackage{tikz} \begin{document} \noindent \colorbox{red}{\expandafter\MakeUppercase\expandafter{\Huge ...
3
votes
1answer
162 views

In LaTeX3, what is the best data type for storing, parsing and outputting free user input?

I'm working on a mini-parser that takes free user input and interprets certain inputs as commands. For example, the parser interprets + as \oplus or [ as "start a pre-configured array with the bracket ...
0
votes
1answer
66 views

Combining texmate header and xskak notation

I tried to alter the PGN2LaTeX3 in that manner that it should create headers in my book, however I failed to do it. for example, some pgn2latex_out.tex result: \newgame \resetPgnTags \def\Site{} \...
0
votes
0answers
32 views

Output position in sourcefile of a macro expansion

Suppose I have a custom macro defined with \newcommand (no fancy parsing going on). For simplicity assume \newcommand{\mymacro}[1]{#1} Is there a way to redefine the macro so that, every time the ...
2
votes
1answer
37 views

Build a shortcut for string to be used as an argument later

I need to pass the result of a macro as a string to another macro (I'm using xparse). Here is a minimum working example: \documentclass{minimal} \usepackage{xparse} \NewDocumentCommand{\...
26
votes
3answers
1k views

Unbalanced dollar signs

I'm curious: why do the following two examples behave differently? Example 1: (Works, displays xyz in displaymath mode.) \newcommand\weird{$$xyz$} \weird$ Example 2: (Error, missing $ inserted.) \...
2
votes
1answer
50 views

Parse standard balanced group within verbatim context

Say I want to write a custom parser which reads characters in a verbatim context, where the parser argument should be split into several kinds of tokens: Ordinary characters, i.e. all characters ...
2
votes
2answers
168 views

Automatically remove \ifthenelse

Let's assume that you have a single LaTeX source file that can compile two arts of documents: a main conference paper and its extended long version. Inside, you use \ifthenese to produce the two ...
0
votes
0answers
94 views

Parse all equations in eps file

When I draw figures with a vector graphic program I can export them as .eps files. I know it is possible to use psfrag to replace given text in the eps file with another text which is then parsed in ...
2
votes
1answer
73 views

Efficiency of xstring (2e) vs. xparse (l3) in simple parsing

I understand string processing can be done on either LaTeX2e using xstring and expl3 using xparse (originally based on the 2013 thread "Tokenizing and parsing") I will be running a relatively simple ...
4
votes
1answer
147 views

Nested maths mode - Latex parsing

I needed a tiny bullet and found this solution : $\vcenter{\hbox{\tiny$\bullet$}}$ Howover, I don't understand how latex interpret / parse this formula. \vcenter is math mode \hbox and \tiny are ...
10
votes
1answer
204 views

How do I define a new TeX register with arguments in LuaTeX?

Some time ago I tried to implement the \pdfadjustinterwordglue from pdfTeX in LuaTeX using a callback. Getting the callback to work is pretty simple, but there is another major problem in the way ...
1
vote
0answers
52 views

How to iterate over tags in a latex file?

I am working on a problem where I have been given a file and I have to find all the cells in all the tables in the latex document(Basically I have to make a border for all the cells. Currently, I am ...
0
votes
0answers
90 views

Split LaTeX paragraphs into new lines after each sentence - re-formatting tool for VCS

I think this question has relevance and overlap on both stack-overflow and TeX forums, but suspect the TeX community might be better suited, so have posted it here. My text/tex files need ...
1
vote
1answer
121 views

In what ways can one write a parser in plain TeX or packageless LaTeX?

I want to write my own document class as a literate program with as minimal of a dependency tree as possible as an exercise to test my ability. I've implemented a stable foreach loop by shredding an ...
0
votes
1answer
59 views

How much negative space needed? To recognizably remove a space by letting something be added? For macros whose argument is another macro?

Suppose that one has brea + (notice the space at the end). brea + is not printed yet. A macro \m{brea +} will replace + with \added ... how then does one define added, imagine it prints a d but only ...
4
votes
3answers
183 views

Extract more than nine arguments that occur periodically in a sentence to use in macros in order to typset

What is a good way to write a definition of the type \fun below \fun{abc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ...} where the number of arguments is not ...
1
vote
0answers
34 views

Latex3 replacement for \afterassigment in parsing code to grab integer

When parsing expressions, one way that I like to grab an integer delimited on the end by any nonexpandable token that is not a digit is using a count register and \afterassignment. So the code looks ...
3
votes
3answers
168 views

Check whether String represents valid number for PGF

I am searching for a reliable way to determine whether a String can be fed into \pgfmathprintnumber. I used to use the \IfDecimal from the xstring package which works fine for things like 3.14 and ...
2
votes
1answer
171 views

Iterating over characters of a string during a for each loop in a Tikz picture

I am trying to make a command that renders a Tikz picture in which there is a square surrounded by a number of smaller squares on the boundary. The first parameter defines the size of the picture, the ...
6
votes
2answers
2k views

Parser for pure LaTeX

Is it possible to create a parser for pure LaTeX (no plain TeX, no TeX primitive) without using any TeX engine that supports total LaTeX? I know about an iOS app to create and typeset LaTeX and I don'...
3
votes
0answers
420 views

Is there a BNF grammar of the LaTeX format?

I know it seems like there is no BNF for TeX language. But I am interested in BNF, PEG or any other kind of formal grammar for the LaTeX format. Is it possible to create such a grammar for pure LaTeX ...
1
vote
1answer
79 views

Stripping leading characters from command parameter

I have a command (AlertShort) with one input parameter that both prints text and generates an index. For standard text this works fine but, in some cases, the input parameter contains a symbol which ...
1
vote
1answer
220 views

LaTeX Grammar and Nesting Rule

Is there any grammar and rule describing the allowed nestings and combinations and the allowed format of the arguments in LaTeX? E.g. \section{\verb|mySec|} \section{\begin{huge}mySec\end{huge}} \...
3
votes
1answer
314 views

LaTeX Nesting \verb in \section

Why is \section{\verb|mySec|} invalid LaTeX code.
2
votes
1answer
86 views

Latex reformat text structure

Say I have a file of abbreivations.txt &Estimated &Time of &Arrival &North, &East, &West, &South &Special &Weapons &And &Tactics &W&ireless &F&...
8
votes
4answers
479 views

Runaway argument? with \newcommand[2]

I have a date (in the format YYYY.MM.DD) and a time (format HH:MM). From these, I want to compute a kind of TimeStamp/Total of minutes. \documentclass{article} \makeatletter % Timestamp \...
1
vote
1answer
316 views

Runaway argument? with \def

I have a time value in the format HH:MM (i.e 03:00). I need to compute the TotalMinutes of this time (expected result 180). My current code is \documentclass{article} \makeatletter \newcommand{\...
1
vote
1answer
133 views

Parsing function arguments and brackets

I've been trying to get a macro to work without any kind of success. I want a function \graf{} to take a list of arguments separated by a semicolon. These arguments need to be passed to the function \...
8
votes
4answers
444 views

Check for group as argument (expandable)

I want to check whether an argument of a command is fully contained in a pair of curly braces without using any extra packages. For this I define two macros containing { and } with catcode 12, ...
11
votes
6answers
725 views

How to go about creating custom parser in Latex

Say I wanted to write a macro like this: \makelinesegment{1:1-1:2-2:2} And have it become something like: \draw (1,1) -- (1,2) -- (2,2); The question is, how to go about parsing that 1:1-1:2-2:2 ...
5
votes
1answer
169 views

Control symbol formed by escape character followed by return

Does the control symbol obtained by following the escape character by return (\<return>, catcode 0 then catcode 5) behave like the control space character (\<space>, catcode 0 then catcode ...
11
votes
2answers
487 views

When is \catcode executed?

According to the TeXbook, characters in a file are first converted to tokens with catcodes ("mouth") and then any nonexpandable commands are executed ("stomach"). \catcode is a nonexpandable command, ...
11
votes
1answer
4k views

How does “\char`” work?

In LaTeX, you can use \char` followed by a symbol to get that symbol. For example \char`b or \char`\b would just yield the letter b. Which symbols/letters does that work for? Two ...
7
votes
1answer
824 views

How to increase minimum space between words in XeLaTex output?

Update: The problem seems to be that the spacing between some words is too small, and the ATS thinks it's one word. So, the ideal solution would be to set a minimum spacing across the entire document,...
4
votes
1answer
2k views

Load fields from JSON file using LuaLatex

I want to load a lot of numbers in my document from a single JSON file that is returned from a simulation. To do that I so far followed this stackexchange answer but for multiple values I would have ...
0
votes
0answers
138 views

Compute image ratio based on the largest picture available in the document

Following this question I asked a few years ago, I'm looking for a way to find the width of the largest picture (in width) in my document. Typically, this requires a for loop and some TeX programming....
3
votes
1answer
243 views

Automated Code Listing Line Numbers

I want to automate source code examples in my documentation. Listing comes very close to doing this as it allows specification of start and ending line numbers: \lstinputlisting[firstline=300,...