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

4
votes
1answer
37 views

How can I determine the size of an array containing macros with optional parameters?

I am using my solution from How can I determine the size of an array? to count the number of entries. However, the \foreach/\IfStrEq in \SetArrayLength seems to have a problem when an entry is macro ...
7
votes
3answers
77 views

String comparison

\documentclass{article} \usepackage{xifthen, xstring} \newcommand{\IfOne}[3]{ \if\TokenIsIn#1 #2 \else #3 \fi } \newcommand{\IfTwo}[3]{ \ifthenelse{\equal{\TokenIsIn}{#1}}{#2}{#3} ...
1
vote
1answer
25 views

converting file: url to path

I am creating LaTeX files using a template engine. The problem I am running into is that the template engine is designed for generating web pages and generates URLs for external files, such as images. ...
4
votes
2answers
49 views

How to use \nameref with xstring package to check string length

I need to measure a number of characters in string, that I returned from label through \nameref command. Here is my MWE: \documentclass{article} \usepackage{hyperref} \usepackage{xstring} ...
1
vote
2answers
41 views

Use numbers stored in a command by spreadtab

My aim is to create a command to store numbers and calculated in the table. \begin{table}[h] \npthousandsep{,} \STautoround*{0} \begin{spreadtab}{{tabular}{| l | r | r | r |}} \hline ...
1
vote
0answers
15 views

transform variable-content to verbatim-like representation inside a newcommand (used then as optional argument)

I spend 8 hours in solving this, made some progress but now face the enormous difficulties with verbatim stuff in latex. Any help would be great! My aim: the todonotes package offers an inline ...
2
votes
1answer
48 views

Truncate parameter before newline

I want to truncate (cut/shorten) a string that contains newline (\\ or \newline) in such a way that only the first line remains. My problem is, that I use the todonotes package and have command ...
2
votes
1answer
37 views

How can I implement xstring's \IfBeginWith equivalently in a non-user-level macro?

I have a string check macro \IfBeginsWith from xstring that is wrapped in a non-user level macro. I have learned here that the wrong approach would be to use user-level commands in a wrapper that no ...
4
votes
2answers
116 views

Multi-substring replace

I'm attempting to automate Werner's answer to my question here. In short, in order to sort the Norwegian letters Æ Ø Å (they come at the end of the regular Latin alphabet) correctly dtlsort needs ...
5
votes
2answers
77 views

\lowercase with \IfSubStr and \StrDel

I'm trying convert an argument to lowercase, strip out the spaces, and then search for the resulting string in a list. Thus far, I've had no luck. Here's the code I would instinctively expect to ...
8
votes
2answers
70 views

Applying and doing math on two functions read from a file using pgf

I'm trying to read two functions of x from a file, and then get the result of f(8) / g(8) using pgfmathparse. Here is a minimal (not) working example: \begin{filecontents}{data.dat} f(x) g(x) x ...
3
votes
1answer
71 views

How to test if two macros have identical definition

I want to test if two macro have identical definition. My naive attempt to use \detokenize does not seem to work in this simple case. However, I have used a similar approach before and it seems to ...
3
votes
1answer
45 views

truncate headings when they have macros in them

EDIT: @egreg, I copy-pasted your document with \expandonce, but if I put a subsection with a macro inside, \subsection{\textit{EE} LEFTshort subsec}, then I get the error Missing control sequence ...
1
vote
2answers
58 views

Language detection and condition

My problem is quite simple. I use the babel package and depending on the language I want to display something with respect to the active language. Therefore I use the package xstring. My code is the ...
2
votes
2answers
82 views

get part of the filename in the file content

I would like to print only the characters between Ch and - in the filename, so I use the packages currfile and xstring. As example : \StrBetween[1,1]{\currfilename}{Ch}{-} should gives 2 or 14 if ...
6
votes
2answers
488 views

Using xstring to check .tex file name

I am having difficulty in using xtring to check the file name of the .tex file. All three of the cases shown below produce the wrong output. Surprisingly in my actual more complicated usage, the ...
1
vote
1answer
115 views

Convert numbers in string to string

I store some strings in a variable \def\nomVAR{A12Z4E} and I want to create some other command using the content of \nomVAR. LaTeX doesn't accept to declare variable with number in its name. So the ...
4
votes
3answers
83 views

LaTeX xstring \StrCut with macros

I've been trying to give some formatted input to \StrCut from the xstring package in a very complex code, and I've been getting an error. Here is a MWE : \documentclass[a4paper]{article} ...
2
votes
1answer
23 views

Defining command \file#1 and use it with \input command, and counter \thefile#1

I would like to define a command as \file#1 in order to use it with \input{\file#1}, where #1 is a entry given, as well as counter \thefile#1 The MWE is the next code \documentclass{article} ...
4
votes
1answer
48 views

Problem with pdfstrcmp

i'm trying to store a three-digit parameter (101) in three different variables by using substrings. Depending on the input, i want to put one to three different icons in the upper right corner of an ...
2
votes
1answer
81 views

When using \IfEq to compare strings, is it one of those times when I should use an expandable xparse command?

I recently asked How can I migrate commands and environments from LaTeX2e to LaTeX3? [XeTeX] While that question is good, the answer is likely quite complex and would take a some time to effectively ...
2
votes
1answer
34 views

Problem with \IfStrEqCase combined with \StrChar

Upon compiling this minimal example \documentclass[12pt]{article} \usepackage{xstring} \newcommand{\digit}[1]{ \IfStrEqCase{#1}{% {0}{zero}% {1}{one}% {2}{two}% ...
2
votes
1answer
51 views

Case Sentence With xstring

I have a LaTeX document that gives me the following error: ! Argument of \@xs@IfStrEq@@ has an extra }. The document is as follows: \documentclass{article} %PAQUETES ...
3
votes
1answer
166 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 ...
3
votes
1answer
86 views

TiKz for each iteration over spaced string argument has an extra }

This is an example of the functionality of a macro, that should the following: iterate over a spaced string and print the first letter of each part. \newcommand\text{\StrSubstitute{a b c}{ }{,}} ...
4
votes
1answer
98 views

Carry out substring replacement on variable's contents

Say I have a variable that contains some non-plain text, for instance \def\var{Caro \textit{et al.}}, and I want to make a substring substitution of Caro for \underline{Caro}. If I try to follow the ...
3
votes
1answer
63 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
82 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
69 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 ...
5
votes
2answers
145 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
61 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
27 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
89 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
61 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
88 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
63 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
82 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
49 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
207 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
43 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
181 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 ...
5
votes
3answers
124 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): ...
4
votes
1answer
131 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{% ...
6
votes
5answers
346 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
161 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
122 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
59 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
1answer
69 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} ...
4
votes
2answers
92 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 ...
3
votes
2answers
233 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 ...