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

learn more… | top users | synonyms

3
votes
1answer
27 views

Refering to colors using numbers

I want to create a command allowing me to colour arbitrary text with a color designed by a number (e.g. 1 = Green, 2 = Blue, etc). To that purpose, I create a first command, giving the name of the ...
6
votes
4answers
141 views

How to match last substring

I am working on displaying source code for which I pass a path to a macro. Now I am wondering if it is possible using xstring or stringstrings to match from after the last delimiter, i.e. / to the end ...
2
votes
1answer
27 views

Using xstring with translator

I wrote the following code to extract the first letter of weekdays, as provided by the translator package: \documentclass{article} \usepackage{xstring} \usepackage{tikz} \usetikzlibrary{calendar} ...
7
votes
2answers
123 views

Comparing strings extracted from Jobname

I have some code that parses \jobname, but it's not working as expected. I've included a minimal example below where the file name is HelloWorld.tex. When I print the \jobname, it comes out as ...
4
votes
1answer
32 views

Passing escaped special characters for use as a URL through macros

From an earlier question on Escaping special characters for use as a URL, using \string to escape the special URL characters in the second example works great: \DefineMyFormatLinkParameters{% ...
5
votes
3answers
82 views

Issue: string manipulation with links inside

I have defined a new command \openintro which I call at every chapter of my work. This command basically constructs a lettrine sentence, like the image below (don't bother with text style): ...
6
votes
5answers
178 views

How to get the number of occurrences of characters in a string

How to get the number of occurrences of characters in a string? \documentclass[14pt]{extarticle} \usepackage{xstring} \usepackage{forloop} \usepackage{ifthen} \usepackage{pgfkeys} ...
4
votes
2answers
86 views

Active spaces with xstring's StrSubstitute

I have some text that I would like to preprocess using xstring's \StrSubstitute method (basically replacing certain keywords by simple commands such as foobar by \emph{foobar}). There are two side ...
0
votes
1answer
34 views

Get first letter of the document title

I'm trying to get the first letter of the document title, but I'm not getting. I'm using a code as: \usepakage{xtring} \StrLeft{\thetitle}{1}[\firstletter] Result of compilation: Undefined control ...
2
votes
2answers
49 views

Functions not working well together

I'm developing a interface for setting and changing distance parameters for a package. These distances are stored as strings so that the user can specify them in em and ex units if they want and ...
4
votes
2answers
47 views

Delayed expansion of StrSubstitute argument with active characters

This is an extension of my previous question. The accepted answer provided a way for me to delay expansion of a marked-up easylist list until the string was processed inside the environment. I'm ...
4
votes
1answer
51 views

Command doesn't expand into other commands after string substitution

The MWE should explain it all (use LuaLaTeX): \documentclass[11pt]{memoir} \usepackage[T1]{fontenc} \usepackage{fontspec} \usepackage{xstring} \usepackage{easylist} \begin{document} ...
3
votes
2answers
140 views

Substitute string that contains a backslash

I need to create a function that will transform a string such as: Hello\textbackslash{}Bye into this: Hello \\ Bye I have tried using StrSubstitute (from the xstring package) without success. I ...
4
votes
4answers
100 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 ...
5
votes
2answers
106 views

How to get \ifcase to work with a macro argument

How can I make the \ifcase statement accept my \myindex macro as an argument in the following example. On its own, the \myindex macro expands correctly, however, I get an error when I use it as the ...
3
votes
1answer
80 views

Nested or variable functions of xstring

My idea is to use xstring package for dealing with some string tests. In my case, I used the \strLeft function for extracting the 3 first letters of a string. Then, I use this result in \IfStrEqCase ...
0
votes
1answer
115 views

Replacing placeholder text in LaTeX \input file

I am using the Dia graphics editor and exporting my diagrams to TikZ code. I am trying to address Dia's inability to easily typeset formulas e.t.c. by using LaTeX for this part. Unfortunately that ...
2
votes
1answer
36 views

Setting hyperref reference with xstring

I am trying to generate hyperref links programmatically, using xstring. For example, in the code below I would like \hyperref[reference\FirstNumber{1,2}]{first line} to be equivalent to ...
9
votes
2answers
211 views

Replace every backslash in a string with a forwardslash

I would like to replace every backslash \ inside a macro (string) with a forwardslash /. The macro is intended to contain a filename in Windows notation which should be replaced by a valid (La)TeX ...
6
votes
4answers
133 views

Using MakeLowercase and StrSubstitute together

I'm using LaTeX and have a string that I want to remove underscores from, and convert to lower case (in either order). The individual steps work: \MakeLowercase{AB\_CD} \StrSubstitute{AB\_CD}{\_}{} ...
10
votes
1answer
146 views

Why can't I expand \ref*{} as a string?

In the following code, if you change \def to \edef the code crashes. Nor can you perform normal string operations or tests. Removing hyperref (and replacing \ref* with \ref) works fine with \edef. ...
3
votes
0answers
64 views

Biblatex ibid in lowercase if prenote is present

I've defined my own biblatex style (see MWE) which uses citations in footnotes. I've patched the prenote command, because otherwise biblatex writes the prenote text in lowercase (note: I don't want to ...
4
votes
1answer
80 views

Centering \dot in a symbol macro (\listofsymbol)

I was trying to achieve the results of get a variable listed in listofsymbol's generated list, when called with a -dot suffix. If was trying also to find a way to center dot in variables with ...
3
votes
1answer
87 views

How to modify Bibtex URL tags in Latex?

I want to cut the URL tags defined in a Bibtex file. For example I want to crop the prefix "mailto:" so that it won't be shown. But the hyperlink still has to contain it. The following command does ...
4
votes
2answers
79 views

xmakefirstuc combined with MakeTextLowercase

I am trying to convert a string as in the example, with all lowercase characters except the first. However, xmakefirstuc does not like me that much. Here's my MWE: % arara: pdflatex ...
2
votes
1answer
68 views

Retrieving text from a “database text” file

I refer to my question and the solutions in String comparison in \ifthenelse I hope I can make my question clear enough, I am not a technician. I use a kind of database file (simple text file) with ...
9
votes
3answers
154 views

Generating a table based on a list and a number of columns

Sometimes a table is used to compact a large number of items. Example: a b c d e f g h j k l Instead of listing all items separately. We want to define a command that eases the implementation of ...
3
votes
1answer
95 views

includegraphics and xstring package

I would really like to do something like the following: \includegraphics{\StrSubstitute{No Spaces}{ }{}} However, this gives me an Undefined control sequence error. I saw some other posts about ...
3
votes
1answer
88 views

makeidx, xstring, forloop and utf8 conflict

I'm using Danish characters in strings that I split with \StrCut from the Ă—string package and use within a \forLoop from the forloop package. The result is not good. Consider this small example: ...
5
votes
2answers
92 views

Replacing substrings by linebreaks

I have a LaTeX document with several authors that I enter like \author{First Author \& Second Author \& .... In some places in the document I want to print these authors with a linebreak ...
6
votes
1answer
71 views

Substitute string in subscript

I want to define a command to shorten formula like this a^1,\cdots,a^n, using a placeholder (-) instead of index, the code is \usepackage{xstring} ...
4
votes
1answer
112 views

Extract from a token containing a list with math content

I have a token which contains a list consisting of: a date in YYYY-MM-DD format, followed by a colon, and some text which may contain math. The text will consist of a sentence or two (i.e., no ...
2
votes
1answer
190 views

Underline/Bold/Highlight multiple names in a bibliography

This is a variation of the question posted here: Now I want to highlight multiple names in a bibliography. Here is the erroneous solution that I tried. \documentclass[11pt,letter]{article} ...
3
votes
2answers
124 views

Generate comma separated list with some non-empty strings

I'm trying to generate a comma separated list that uses strings that may or may not be empty. For example \mylist{\stringA,\stringB,\stringC} would expand to A, C if B is empty or B, C if A is empty, ...
2
votes
1answer
155 views

gitinfo (xstring): tag info does not work because of “tag:” before version number

I'm making the switch from subversion to git, and I'm quite happy with the gitinfo package. The only thing I cannot get to work is to show a version number from the tag. I have identified the ...
2
votes
2answers
126 views

How do I use IfStrEqCase within a siunitx command?

I am having trouble using \IfStrEqCase from xstring inside \num from siunitx: \documentclass{article} \usepackage{xstring} \usepackage{siunitx} \newcommand{\bla}[1]{% \IfStrEqCase{#1}{{a}{1}% ...
8
votes
1answer
132 views

\IfStrEqCase having problem with last optional parameter

It's been a while since I asked an embarrassing question, and am pretty sure this is another one of those: This code below attempts to use \IfStrEqCase from the xstring package and results in: ...
6
votes
3answers
169 views

xstring test for numbers within a range

I'm working on a document command that has a variety of optional arguments for different results. I need to add an option that yields 'true' for an optional argument within a range of numbers, for ...
2
votes
1answer
182 views

Latex: splitting/processing strings inside a latex command

Let's say I have \ingredients {% \unit[375]{g} & Farina 00\\ \unit[250]{g} & Burro\\ \unit[3]{g} & Sale\\ 1 & Limone } (you got me: I'm dealing with xcookybooky) ...
5
votes
2answers
145 views

How to use xstring commands in biblatex DeclareFieldFormat?

I'm trying to tweak a biblatex bibliography. One problem is the rendering of entries with eprint fields. Sometimes, I have something like eprint = "hep-ph/0207124", sometimes its ...
4
votes
1answer
201 views

How to remove the first and last letter of a string

My example. Need from the string "$${{15}\over{4}}$$" get the string "${{15}\over{4}}$". \documentclass[14pt]{extarticle} \usepackage{xstring} \usepackage{amsmath} \def\f(#1){(#1)^2-5*(#1)+6} ...
8
votes
2answers
144 views

Illegal parameter when nesting commands

I keep getting illegal parameter errors when trying to define a command that contains another previously defined command. I know that you have to be careful with nested definitions, but I didn't think ...
4
votes
1answer
133 views

Loading file after converting to ASCII characters

I am writing a document on phonetics using the media9 package to include pronunciations of some of the words in the document. The words that are to be pronounced are in Danish, and thus their ...
5
votes
1answer
206 views

Forcing the first choice of an newtcblisting environment

I have created a new environment based on "tcblisting" from package "tcolorbox" is code (MWE) is as follows: \documentclass[10pt]{article} \usepackage{tcolorbox} ...
5
votes
1answer
108 views

Using xstring macros in edef

I've tried to use \protect to make the following \edef work but no luck. Can it be done somehow? \documentclass{article} \usepackage{xstring} \begin{document} \def\abc{a,b,c} ...
2
votes
0answers
217 views

Why can't I get a conditional command to work in a macro invoked within a tikzpicture?

I wanted to create a macro that can be invoked in the middle of a tikz path and behave differently, conditional on one of the arguments. Here is an example document: \documentclass[a4paper]{amsart} ...
4
votes
0answers
139 views

How to include part of an external git hash as text inside a document?

This is my first time asking a question on a site like this. Please tell me if I should do something differently, thanks! I want to include a short version of the latest commit hash from git as a ...
8
votes
1answer
145 views

Undefined Macro in Package xstring

I have a very basic problem. I am trying to use the xstring package in a Latex document and I keep getting the following error message for an undefined control sequence: (c:/Program Files ...
9
votes
3answers
230 views

Command doing the same job as StrBefore but being expandable

I am looking for a command allowing me to get 3 as output if the input is 3.2. \StrBefore{3.2}{.} works fine for this purpose but is not expandable and I need to call it in another macro inside a ...
2
votes
1answer
95 views

How to use \StrBefore in \chapter with optional argument

I want to trim the chapter titles in toc up to first dot. \documentclass{book} \usepackage{xstring} \newcommand{\chap}[1]{% \chapter[\StrBefore{#1}{.}]{#1} } \begin{document} \chap{Some title. ...