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

How to get xstring methods variables work with pgfmacros and vice versa in all situations?

I am trying to draw simple graph with my command: \documentclass{article} \usepackage{tikz} \usepackage{xstring} \usepackage{float} \begin{document} \newcommand{\lT}[4]{ \draw[line cap=round, line ...
3
votes
1answer
34 views

Character replacement in unicode string

I need a command to replace (erase) the characters · and | from a string. Consider the following naive code: \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} ...
3
votes
2answers
35 views

Formatting Strings in Dynamic Variables with xstring

I need to format a string resulting from a dynamic variable set in a separate program for a LaTeX generated report. In particular, if a variable has a negative value (starts with a minus sign), I ...
4
votes
2answers
65 views

Formatting String in LaTeX Macro Containing Dollar Sign (\$)

I am writing a macro that formats strings based upon their values in a LaTeX report. I have run into an issue in which a string containing a dollar sign (\$) will result in an error. Here is a ...
1
vote
1answer
35 views

How to use variable in function call

I get data from a csv file using the datatool package: DTLgetvalueforkey{\thenames}{NAMES}{data}{BD}{#2} \ifthenelse{\equal{\thenames}{\dtlnovalue}}{}{ \specialtext{\thenames} } based on ...
1
vote
1answer
19 views

Store the result of IfSubStr and then count with StrCount

I want to store the result of IfSubStr (from package xstring) for using it later. So I define a command and I redefined with the result of IfSubStr. So far, so good. But now I want also to use ...
3
votes
1answer
49 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
43 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
46 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
32 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
64 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
44 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
167 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
34 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
139 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
64 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
107 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
204 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
111 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
54 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
51 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
60 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
64 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
175 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
113 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
152 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
124 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
133 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
42 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
240 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
162 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
162 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
105 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
92 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
98 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
91 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
91 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
160 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
123 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
99 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
108 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
81 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
128 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
259 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
142 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
173 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
138 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
146 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
191 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
206 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) ...