As of May 31, 2023, we have updated our Code of Conduct.

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
0 votes
1 answer
37 views

How to recreate this CYK parse table

I would like to use something that looks like the following table in my document, but I have no idea of how to make this using TikZ or other packages. Using a matrix leaves too much empty space above ...
Dexterous's user avatar
0 votes
1 answer
61 views

My wheel chart displays fine but I have an error in the logs

I am trying to create a wheel chart and it displays almost fine but i still have an error: Package tikz Error: Cannot parse this coordinate. ‪main.tex, 32‬ See the tikz package documentation for ...
Balansoire's user avatar
0 votes
0 answers
38 views

Parse Subscripts and Superscripts in Nested Macros

How can I parse subscripts and superscripts in nested macros? I am trying to write two macros based on this answer: underlinemacro: underline the input argument excluding subscripts and superscripts. ...
C. Taylor's user avatar
3 votes
4 answers
63 views

Parsed word segment in second function can not be compared to string in latex?

I would like to parse words by removing always the last segment ("1. Book1 p3" becomes "1. Book1" or "Book2 p4" becomes "Book2"). This I achieved with the ...
ISE's user avatar
  • 31
0 votes
1 answer
46 views

Language question: with \x defined as <X>, why using command \x is not the same as using <X>

This is intended more as a LaTeX language question than a "how do I accomplish XYZ" question. In the code below, a usage of VerbatimOut is successful. Place that usage inside a \newcommand* ...
David Fink's user avatar
3 votes
2 answers
87 views

How to make plain text be understood as a macro?

I'd like to create an environment, which will have its own parsing rules inside, for example: \begin{foo} a := 42; c := a; \end{foo} Would be understood as: a \mapsto 42 \\[2pt] c \mapsto a \\[2pt] ...
yegor256's user avatar
  • 11.2k
1 vote
2 answers
39 views

Using string to process a macro name using listofitems seems to fail

I am trying to process the name of a command using listofitems, but when I am using \string to convert that command it does not behave the way I think it would behave. Here is a code to illustrate: \...
Vincent's user avatar
  • 4,527
0 votes
0 answers
19 views

Macro/variable numerical operations with values read from other files

I'm using Overleaf currently to work on some .tex documents and figured out there were some long-term improvements I could make for the project with macros. I personally want to make a macro that ...
JLin's user avatar
  • 1
7 votes
5 answers
326 views

Does a package exist for programmatically (incrementally) constructing a macro?

When using LaTeX, I often find myself desiring a way to programmatically construct a macro using a series of instructions rather than in the usual "template" sense. By "programmatically&...
COTO's user avatar
  • 361
2 votes
0 answers
79 views

Detect \end of an environment

I'm trying to create a macro that grabs everything till the end of the current environment and parses it. At first, I just want to put ! right after my macro and another one ! before the end of ...
antshar's user avatar
  • 4,076
1 vote
1 answer
84 views

How to parse an itemized list the way moodle.sty does

A simple moodle.sty database contains code like that: \begin{multi}{Name of the question} Text of the question \item first answer \item secon answer \item* the starred is the ...
user126154's user avatar
2 votes
2 answers
133 views

How to gobble a character, if present

I would like to do the folloging: Given a (complicated) string/macro \String, if it starts with * I just remove it, otherwise I do nothing. So far I tryed \def\gobbleast *{}% then \gobbleast \String ...
user126154's user avatar
0 votes
0 answers
305 views

Is there a way to extract math from a pdf in LaTeX format using SESHAT?

So I've been tasked with using SESHAT to extract the math problems from a large pdf into latex format, but seshat requires an InkML or SCGink file type as it's input. Is there a way I can convert pdf ...
JustLearning321's user avatar
2 votes
1 answer
129 views

Parse subscript and superscript in command

I am using quite a lot of notation in my text. Thus, I decided to write some commands such as: \newcommand{\struct}[1]{\mathsf{#1}} The typical use is as follows: Let $(\struct{A}_n)$ be a sequence ...
Tomáš Hons's user avatar
0 votes
0 answers
86 views

Coloring numbers outside string and variables using lstlisting and parsing don't work as expected. Need Help to fix with PDFLaTeX

I am writing my thesis and i need to put extract of code into it. Having developed all my C# code in Visual Studio, I would like to have more or less the same colors, so I have taken different ...
Matteo Di Fabio's user avatar
7 votes
3 answers
238 views

Are there any LaTeX commands (including in packages) where the argument will be in math/text mode based on context?

As I work on the parser for finl, I'm contemplating how I'm dealing with command parameters and wondering if my current setup is sufficient. Right now, a parameter has a type which would either be ...
Don Hosek's user avatar
  • 13.5k
3 votes
2 answers
192 views

Parse list of tuples

I want to pass a list/sequence of "tuples" to a macro, like this: \foo { (value11 value12 value13) (value21 value22 value23) (value31 value32 value33) (value41 value42 ...
Noldorin's user avatar
  • 830
1 vote
2 answers
163 views

Gobble the next char if it is whitespace or tilde

I want this macro to gobble the next character in the input stream only if it is whitespace (according to the char code) or it's the tilde character (i.e., a non-breaking space). My current attempt to ...
Noldorin's user avatar
  • 830
4 votes
3 answers
103 views

How to absorb the content of the page into a variable?

This is what I'm trying to do: \documentclass{article} \begin{document} \start Hello, world! \stop \print % here! \end{document} I'm expecting Hello, world! to be printed twice. The second time by ...
yegor256's user avatar
  • 11.2k
6 votes
3 answers
308 views

Split string into part by char position

Explanations I format a moroccan RIB (Relevé d’identité bancaire for “Bank account number”) to display it as a nice rendering. I need to take each part of the RIB to embrace it with a specific label. ...
fauve's user avatar
  • 2,233
1 vote
1 answer
57 views

Macro delimited lists

Floats use macro delimited lists like \@freelist. Source2e shows them using macros like \@next and \@cons without showing the definitions. The idea of having self parsing lists is intriguing and ...
John Kormylo's user avatar
  • 75.3k
1 vote
2 answers
130 views

Automatically composing documents from multiple text files which are not LaTeX formatted?

I'm looking for a way to create a songbook out of individual song files. Each song file is a self-contained block of text data consisting of: Song name Song author Some details (optional) Lyrics with ...
Petr Doležal's user avatar
9 votes
4 answers
505 views

LaTeX3 - Parsing an argument to apply specific macros

In the following code, I would like to parse the argument of \parseanduse such as to "achieve" the examples shown. Each time a o is met, the following integer should be used to call the ...
projetmbc's user avatar
  • 12.9k
1 vote
1 answer
145 views

ConTeXt: Typeset XML attribute containing newlines

Background A user can provide their address information in a text area, separating lines by pressing Enter. An XML document is generated, which replaces the new line character with \n, such as in the ...
Dave Jarvis's user avatar
  • 11.3k
1 vote
1 answer
268 views

Parsing optional argument from \newenvironment to \newmdenv

I'd like to parse an optional variable from a custom \newenvironment{example} to an mdframed environment \mytextbox nested in the example environment. What I'd like to achieve is something like ...
Jean Jordaan's user avatar
5 votes
1 answer
214 views

Parsing a mix of plain text and commands

I am trying to implement a command that parses some expression that can be a mix of plain text, commands with their (any number of) arguments, or even -- if I understood that correctly -- unexpandable ...
kmft3kte's user avatar
9 votes
2 answers
300 views

LaTeX3: Elegant way to forward-reference a counter with a "future" value

I'd like to do, pseudo-code, the following: \begin{pointtracker}{Advanced Geology} \begin{itemize} \item Count the fingers on your left hand. Are there more than 9? \addpoints{1} \item Draw ...
Marcus Müller's user avatar
1 vote
1 answer
51 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, ...
Christoph Thiede's user avatar
1 vote
1 answer
797 views

Parsing issues with resume written in LaTeX [closed]

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 ...
Andrew's user avatar
  • 111
5 votes
1 answer
224 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{...
Matsmath's user avatar
  • 936
0 votes
2 answers
82 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. ...
Kochise's user avatar
  • 155
14 votes
1 answer
7k 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. ...
vy32's user avatar
  • 4,660
1 vote
0 answers
94 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 ...
MahiPai's user avatar
  • 81
3 votes
2 answers
188 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-...
RazorHail's user avatar
  • 157
6 votes
4 answers
492 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 ...
Jason Siefken's user avatar
0 votes
0 answers
33 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 ...
Ntakwetet's user avatar
  • 611
6 votes
1 answer
408 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 { .....
Kimball's user avatar
  • 303
3 votes
1 answer
394 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 ...
sdaau's user avatar
  • 16.9k
3 votes
3 answers
268 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 ...
Mike's user avatar
  • 376
3 votes
2 answers
323 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 ...
Felix Emanuel's user avatar
0 votes
1 answer
134 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{} \...
Ulvi Bajarani's user avatar
0 votes
0 answers
41 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 ...
Bordaigorl's user avatar
  • 14.9k
3 votes
1 answer
77 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{\...
User12345's user avatar
  • 159
27 votes
3 answers
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.) \...
fmg's user avatar
  • 477
2 votes
1 answer
96 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 ...
siracusa's user avatar
  • 13.2k
2 votes
2 answers
181 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 ...
user avatar
0 votes
0 answers
226 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 ...
mon43's user avatar
  • 101
2 votes
1 answer
104 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 ...
Kompootor's user avatar
5 votes
1 answer
335 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 ...
Matheod's user avatar
  • 440
10 votes
1 answer
315 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 ...
Henri Menke's user avatar