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
39 views

List separated by semicolons, ending with a period

I am using a university-developed document class for my thesis. This class has the command \keywords which takes a list of \key commands and this is printed out as a keyword list after the abstract. ...
3
votes
1answer
35 views

StrChar causes error when used inside tikzpicture

The following TikZ code attempts to make a graph by drawing vertices 1 through 6, then drawing edges from the list. The edges are formatted as 12, 23, etc., so the command StrChar from package xstring ...
2
votes
1answer
40 views

Comparing strings in a class file

I am modifying a correctly functioning class file to add some capabilities. I need to compare two strings - a) \@stringtextfromuser and b) ABC. I have loaded etoolbox, and xtsring and have tried ...
0
votes
1answer
26 views

Xstring Problem with Ş

I want to use xstring version 1.7. However ş and ç cause problems. For instance \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{xstring} \begin{document} \StrSubstitute{ş}{a}{b} ...
4
votes
2answers
57 views

How can I use XString to count characters in a string with the “wrong” catcode?

I created a TikZ coordinate system to solve a positioning problem I had. The code is presented below. However, the code doesn't work; if you run it, you will get the Too many .'s error message ...
3
votes
1answer
42 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
156 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
32 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
136 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
53 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
98 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
193 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
102 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
46 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
55 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
61 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
160 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
108 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
128 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
107 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
129 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
41 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
229 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
149 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
159 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
88 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
88 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
94 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 ...
5
votes
2answers
89 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
85 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
159 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 ...
4
votes
1answer
117 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
91 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
102 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
78 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
121 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
234 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
137 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
169 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
133 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
136 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
184 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
202 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
152 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
247 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
152 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
138 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
223 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
113 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} ...