Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [l3regex]

Regular expressions in LaTeX

0
votes
0answers
50 views

'l3regex.sty' not found

I updated my MiKTeX today. Now, I do not get any error without packages but it can not compile my latex files with packages. Uninstalling and reinstalling both Texmaker and Miktex did not work. I ...
1
vote
0answers
35 views

Replacing a character with other character in all the document, on specific conditions

In Hebrew, there is a special punctuation mark, called Gershayim, that's used to indicate an acronym. It's written before the last character. It looks very similar to quotation mark, and since it ...
0
votes
1answer
374 views

pkgloader is not finding l3regex

I would like to try a package which seems interesting, but it some dependencies are not satisfied. Here is my minimal example: \documentclass{article} \usepackage{pkgloader} \LoadPackagesNow \...
2
votes
1answer
59 views

Is it possible to use \regex_replace_all instead of \tl_replace_all

I have the following macro definition: \let\hlORIG\hl \ExplSyntaxOn \tl_new:N \l_jdhao_hlx_tl \RenewDocumentCommand\hl{m}{% \tl_set:Nn\l_jdhao_hlx_tl{#1}% \tl_replace_all:Nnn\l_jdhao_hlx_tl{\ }{~}...
7
votes
0answers
205 views

Convert all all-caps words to small caps #2

A question very similar to mine was asked before, but I assume that there are others with the same issue and that there are other solutions. I know several academic publishers that don't like ...
0
votes
1answer
63 views

Biblatex: brackets and no bracket

I would like to know whether it is possible with biblatex and pdflatex to automatically select the in-text look of the \cite command, with the author-year style. For instance, I would like citations ...
7
votes
1answer
69 views

latex regex remove word

I am using the hyperref package and I want to make a command for writing \hrefs once with their protocol removed. For example, https://google.com becomes linked google.com http://google.com becomes ...
0
votes
1answer
72 views

Macro with regular expression

I want to use \def or something similar so that every time I write \n, with n a number, it converts to \textbf{n}. I know I can use \def with arguments and that would be a workaround but I'm curious ...
6
votes
2answers
62 views

listings: highlight a prefixed keyword starting with a single quote

This is about Rust and their lifetime notation: \documentclass[crop,varwidth]{standalone} \usepackage{listings} \usepackage{xparse} \usepackage{expl3} \usepackage[svgnames]{xcolor} \def\noprint#1{} ...
2
votes
1answer
73 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&...
3
votes
1answer
44 views

Expl3 regex and missing semicolon?

Try to make an answer to this question How to go about creating custom parser in Latex, I have the following problem. The result of the macro seem no conform to what I expect : (1:1)--(-1:2)--(2,2) ...
2
votes
1answer
57 views

Regex within new command to prevent making tooltips of tooltips

I'm making a document where I want the definitions of entries in the glossary to appear as tooltips. The tooltip code itself is from the answer: Can't embed hyperlink references in a tooltip ...
3
votes
1answer
48 views

Upper- or lower-casing input based on the case of the first character

For some sequence of characters, I want to change the case of all characters to match that of the first. So for example, aBCD → abcd and Abcd → ABCD. My naïve attempt to do this in LaTeX3 did not ...
2
votes
2answers
272 views

Multi-stage regular expression replacement

I'm trying to write a macro which will recognize certain sequences of characters in a string, and then map those onto a different set. In the particular case I have in mind, since there are multiple ...
6
votes
3answers
252 views

Translate xfp notation via l3regex to LaTeX notation

using the xfp package to calculate mathematical terms works fantastic and I am trying to automate some things to also make the \fp_eval:n input also presented properly with LaTeX notation. My attempt ...
1
vote
0answers
41 views

Why can't I use LaTeX3 commands inside a macro I define? [duplicate]

I'm really wanting to make use of LaTeX3's regular expressions package (l3regex) but am struggling to use LaTeX3 commands in general. Code that works on its own in the preamble fails when embedded in ...
12
votes
1answer
472 views

Are LaTeX3 regular expressions able to match characters at the start of a line?

I would like to use LaTeX3 regular expressions to extract the "lines" from text like the following: - First line - second line ending with \LaTeX - third line with - in the middle - fourth line that ...
3
votes
1answer
123 views

Detect single initial with l3regex

Edit: Now my problem is detecting when the argument to \mkbibnamegiven is a single initial. I'm trying to do that with l3regex but I can't get it to work: \documentclass{article} \usepackage{lmodern} ...
3
votes
1answer
142 views

Regular expression weirdness

In answering Automatically put certain inputs (e.g. punctuation marks) outside of the environment/command I wrote something very similar to this: \documentclass{article} \usepackage{xparse} \...
3
votes
2answers
96 views

Regular expressions … how to also return the sequence splitting characters?

So, we have this great regex code by User Andrew as an answer to my OP "Automatically put certain inputs (e.g. punctuation marks) outside of the environment/command": \documentclass{article} \...
3
votes
4answers
914 views

How to start with a, b, c,… and end up with 1a2a3, 1b2b3, 1c2c3,

So imagine you have a certain code which looks like this: ABC, some text , LaLaLa \tooltip*{A}{\includegraphics[scale=2]{images/A}}\tooltip*{B}{\includegraphics[scale=2]{images/B}}\tooltip*{C}{\...
3
votes
1answer
102 views

Expand \date with l3regex

I'm trying to extract the current year from the \date command using l3regex to match 4 consecutive numbers from whatever is passed to \date{ ... }. However, I also want to get the year value if one ...
2
votes
1answer
74 views

Extracting a substring from a token list

How does one extract substrings from a non-explicit token list? \documentclass{article} \usepackage{expl3} \begin{document} \ExplSyntaxOn \tl_new:N \l_my_tl \seq_new:N \l_my_seq \tl_set:Nn \...
9
votes
2answers
332 views

Spotting strings that are typos in “text mode” but that are right in “math mode”

My copy editor work is largely dedicate do spot typos. I have a kind of typos formed by strings like, e.g., ".", ",", ":"... (a space before a punctuation sign) that we consider typos in text-mode (...
4
votes
3answers
136 views

How to patch a macro with control sequences using regexpatch

I have partial success patching a macro with regexpatchcmd. I would like to patch a macro that calls another macros. The purpose is that every command in the patched macro becomes inside \string and \...
6
votes
1answer
250 views

Unsigned integer variable in a regex

I need chapter/section specific labels to be generated dynamically for each chapter and section. I have modified the chapter and section command to do that. I use a regex based string manipulation and ...
4
votes
1answer
154 views

Retaining spaces in regex replacement across iterations (LaTeX3/l3regex)

I have run into an issue with spaces when using regex replacement. Not entirely sure if this is expansion related or there is some method to properly preserve the spaces. The current workflow is ...
6
votes
1answer
117 views

Regex replace all on token list which is used as argument for command/function/environment

I am working on a package with a command which creates a new tikzpicture. I would like to pass a list of tikzpicture arguments to the command. For example, for my single argument command, I might ...
3
votes
1answer
265 views

using regex to extract two values (send to macro variables) of unique multiple occurences

I read several key values from a document with bible passages written in spanish like this 1 Corintios 2:4-5; Mateo 15:1-10;Salmos 118:16 I want to extract the citations in each reference (could be ...
1
vote
1answer
58 views

How do I copy the contents of a file with a given prefix to another file in restricted write18 enabled mode?

I know the prefix of a file - and I also know that there exists exactly 1 file with that prefix. I am running pdftex in restricted write18 enabled mode. I want to copy the contents of that file to a ...
9
votes
1answer
352 views

Regex for a string with a command inside it

I have managed to create a command that takes an argument and does substitutions on it with l3regex. However, if the argument contains itself a command, the command name is printed in the output as if ...
6
votes
1answer
135 views

LaTeX3 Regex using control sequence

I'd like replace some words/characters using l3regex on a arbitrary variable. Instead of doing this \tl_set:Nn \l_myname_tl {Hello} \regex_replace_all:nnN {(\w+)} {\1 World!} \l_myname_tl which ...
3
votes
1answer
110 views

Modify contents of environment using l3regex and then write to file

I want to define an environment (in a class file, as it happens) the contents of which are both displayed on-screen as they are written, but they are also modified (e.g. using the l3regex package) and ...
1
vote
0answers
104 views

Expansion to fpeval

This is a followup to Egregs answer in the question Deleting defined variables or assign within group, I am trying to expand the code, but got into trouble while attempting some calculations with ...
2
votes
1answer
67 views

Deleting defined variables or assign within group

This is a followup to Egregs answer in the question Expandable math, The code is included here as an MWE. It would be a great help if I could somehow delete all previeously defined variables, or ...
6
votes
1answer
139 views

Expandable math

I am trying to create a script which expands some easy to read and write commands into more full-blown math formulas which uses variables so that it first prints its names and then on a new line, it ...
2
votes
2answers
76 views

Remove all body text from book class with nested files

I have a long set of notes as a book class where each chapter is added to the master document with \input{}. Each chapter file has sections, subsections, itemizes, enumerates, and body text. I would ...
1
vote
1answer
193 views

How can I apply a regex (l3regex) on items in a sequence? [LaTeX3]?

I am trying to apply a regular expression to a string item from a sequence in LaTeX3. Example Compiles with error, but only by pressing return many times. ! Missing control sequence inserted. <...
2
votes
2answers
96 views

Changing remote path of figures to local path with a regular expression

I am using markdown to write the bulk of my thesis, and then converting it to LaTeX (with Pandoc) for the final presentation. To include graphics I use dropbox share links as: ![MyCaption](http://...
3
votes
1answer
204 views

Does LaTeX support including a specific part of an \input, like a specific environment and ignoring everything else? [duplicate]

Can LaTeX natively include only specific expressions from an input file (ignoring the rest)? I am not sure how to best word my question. Below is an example of what I'd like to do. Situation For ...
5
votes
2answers
117 views

Strange behave of index and l3regex

I am experimenting with LaTeX3 features and get a strange behaviour in a combination from index and l3regex. I try to replace all occurrences of :<space> with the exclamation mark sign, so that ...
2
votes
1answer
125 views

How to automatically put the footnotes before punctuation?

I have little problem :). I have a big file with 1422 footnotes. The problem is that I need to put every footnotes before punctuation (.,;). How to automatically put the footnotes before punctuation? ...
3
votes
1answer
73 views

Extracting the pagenumber of the first page of a section from the toc file

In a project I am working on, I use subfiles to compile a document, each containing one section. If I compile only the document containing some given section, I want the page number to be correct. One ...
7
votes
1answer
894 views

Color each letter in document

I am trying to define a command that changes the color of every letter in the whole document to a specified color. I already tried different approaches from this thread, but I was not able to color ...
1
vote
0answers
79 views

Listings - Keyword with Regex [duplicate]

I would like to colorize in a special color all my constant which are all in capital letters in my code and all my method variables which begin with an @. Is it possible to use Regex to define ...
6
votes
1answer
775 views

Dynamic calculation within regular expression quantifier in LaTeX3's l3regex package

I am trying to do some simple calculations to be applied to a regular expression quantifier used in l3regex's \regex_replace_all:nnN function. I've built my code around what I found here: Defining a ...
45
votes
4answers
2k views

Has the time come for a LaTeX3 successor to 'listings'?

I'm currently looking for a nice and challenging open-source project to work/collaborate on after my thesis. I don't have a Comp. Sci. background, but I'd like to learn more about compiler ...
2
votes
1answer
978 views

l3regex usage throws __scan_new:N error

Using TeXLive, with this MWE \documentclass{article} \usepackage{expl3} \usepackage{l3regex} \begin{document} a \end{document} I get an error for an undefined control sequence (/usr/share/texlive/...
4
votes
1answer
601 views

How can I match a control sequence using \regex_match?

How can I match a control sequence using \regex_match? This code \newcommand{\iw}[1]{\immediate\write16{#1}} \iw{1 should be true} \regex_match:nnTF {May} {May} {\iw{TRUE}} {\iw{FALSE}} \newcommand{...
8
votes
1answer
289 views

Missing space when replacing with \regex_replace_all:nnN

How can I make \regex_replace_all:nnN not remove the space between x y? \documentclass{article} \usepackage{l3regex} \ExplSyntaxOn \cs_new:Npn \replace #1#2#3 { \tl_set:Nn \l_tmpa_tl {#3} \...