Questions tagged [xstring]
provides macros manipulating strings of tokens. For a basic use, tokens can be alphanumeric chars, but the macros can also be useful for manipulating tokens
400 questions
6
votes
2
answers
55
views
Parsing command arguments with xstring within tikzpicture block
I'm trying to write a custom command to automatically adapt the shape of intervals in Tikz. I'm currently trying to pass an orientation argument to the command \intervalle to parse it via another ...
2
votes
1
answer
59
views
Why does aligned remain in \detokenize output despite \StrSubstitute{\temp}{aligned}{}?
I'm using a LaTeX macro to sanitize math expressions for label generation. The macro applies \detokenize to the input and then runs a series of \StrSubstitute commands to remove or replace certain ...
6
votes
3
answers
424
views
How can I automatically replace curly braces { and } in LaTeX macro arguments—e.g., in math formulas—for label generation?
I want to automatically "sanitize" arbitrary LaTeX math formulas (such as \mathcal{P}(A)) into a string that can be used as a label, by replacing all curly braces { with e.g. Lp and } with ...
1
vote
0
answers
67
views
Test if a general text starts with a dash
I want to determine whether a general expression starts with a dash using xstring package. In some cases it fails, an other generates a wrong answer. The below comparisons all should return true, ...
3
votes
3
answers
211
views
Extract and Format time from a URL
I want to extract and format time from a given link. The formatting should be HH:MM:SS. For example from https://youtube.com/watch?v=dQw4w9WgXcQ&t=123s I should get 02:03. I only consider 2 ...
4
votes
2
answers
157
views
lua replacement xstring
The issue appears to be with xstring macros. I am well aware that they are not expandable, so that they cannot be nested. I have a lot of custom code that uses xstring without problem, by storing the ...
0
votes
1
answer
49
views
Use xstring's IfSubStr inside a \begin{minipage} \end{minpage} split across two commands
I have an auto-generated grammar definition. I want each non-terminal definition to be aligned on the "::=" and wrap the productions automatically.
To do this, I use a minipage split across ...
2
votes
1
answer
94
views
Define macro based on substring
I am trying to code a macro that defines a \newcommand, based on a partial string which I input.
\documentclass{article}
\usepackage{xstring}
\newcommand\cmdfullstr[2]{%
\expandafter\newcommand\...
5
votes
2
answers
173
views
\StrSubstitute does not work with arguments passed in a verbatim manner
Goal
I am attempting to redefine an existing command (\mintedinline) which takes a verbatim argument. I need to format this argument such that it can be passed to an outside program for processing; ...
5
votes
4
answers
503
views
Remove any \cite{...} from a string
I would like to remove all citations from a given string. I thought of doing something like the MWE below but it doesn't work.
\documentclass[%
oneside, % Print one sided
...
1
vote
0
answers
86
views
Conditional PDF metadata with hypersetup (hyperref)
I have a problem with providing conditional PDF metadata to different LaTeX documents. I'm using the xelatex compiler and thought I could conditionally set PDF metadata based on the jobname (via ...
3
votes
2
answers
168
views
StrChar on consecutive spaces
I'd like to get characters at specific indices from my argument. I'm trying to use \StrChar, but it seems that it collapses consecutive spaces:
\documentclass{paper}
\usepackage{xstring}
\begin{...
4
votes
2
answers
193
views
SIunitx: complex material in S column
I ran into the following issue. My goal is to read a table from a csv file, format some numbers nicely, and print some data depending on other fields. The following minimal example captures the logic ...
5
votes
4
answers
658
views
Replacing all characters in a string with asterisks
I want to replace all characters in a string by a different character, for example an asterisk. This is my code:
\documentclass{minimal}
\usepackage{multido}
\usepackage{xstring}
\def\mystring{...
2
votes
1
answer
94
views
\IfSubStr inside tikz path style
I don't know whether what I'm trying to do is possible at all, but I really want to make a tikz path style that behaves differently depending on the names of the coordinates it's given.
Here's a ...