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

1
vote
0answers
8 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
32 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
36 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 ...
0
votes
0answers
20 views

Sorting macro-generated text

This is the third in a series of questions concerning sorting Norwegian words. Norwegian has three additional letters, sorted at the end of the alphabet: Æ Ø Å. To help datatool's sort algorithm, ...
5
votes
2answers
60 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 ...
4
votes
2answers
107 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 ...
8
votes
2answers
66 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
69 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
38 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 ...
2
votes
2answers
74 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 ...
1
vote
1answer
42 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 ...
1
vote
2answers
40 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
1answer
22 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
3answers
64 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} ...
4
votes
1answer
46 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
57 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
28 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
47 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
69 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
83 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
59 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
67 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
64 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
119 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
53 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
26 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
71 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
57 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
71 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
55 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
79 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
47 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
196 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
38 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
166 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
116 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
119 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
288 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
147 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
95 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
56 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
82 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
68 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
219 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
122 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
264 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
168 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
175 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
51 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
289 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 ...