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
2answers
165 views

canonicalize file path strings in TeX

I have a package which recursively loads many little modules (essentially tex files) from relative file paths. As modules may load other modules, I have to be careful not to load modules twice, so I ...
6
votes
2answers
427 views

Nesting of test commands (IfStrEq, IfSubStr etc.) of xstring

The following code does not work: \documentclass{article} \usepackage{xstring} \newcommand\checkempty[1]{ \IfStrEq{#1}{}{% Empty }{% NonEmpty } } \begin{document} ...
1
vote
1answer
120 views

Customize text format of captions by parsing content of \@caption

I need the first sentence of my captions to appear on its own line in a \large, bold font. I also need to same document to easily produce standard captions (all same font, no line breaks). I have ...
6
votes
1answer
262 views

Why can't I compare a string with \par?

First of all: the package xstring cannot recognize a \par as argument. When I for example do this: \usepackage{xstring} \def\apar{\par} \def\str{a string} \IfStrEq{\str}{\par}{% true part }{% false ...
5
votes
1answer
126 views

StrSubstitute and @ inside and outside \lstnewenvironment

While further working on code for my answer to Different approach to literate programming for LaTeX, I am encountering a problem to which I am sure there is a very simple solution, but it completely ...
4
votes
2answers
339 views

How to cut chapter title in header using xstring

I need to cut the chapter title that appears at page headers. I'm developing a latex generator software (http://github.com/caelum/tubaina, new contributors are welcome!), and because of ...
6
votes
2answers
372 views

Replacing ampersands in argument

I am trying to define a command which takes as an argument a string containing ampersands, and replaces every ampersand by a space. Following the ideas in Replacing characters in argument strings, I ...
10
votes
3answers
411 views

TeX capacity exceeded while parsing a date string

I'm trying to parse a date (say, a due date) in a DD-MMM-YYYY format, e.g., 06-May-2012 and create macros \dueday, \duemonth, and \dueyear. I use xstring's commands to extract the substrings. Then I ...
8
votes
2answers
251 views

Why are some macros undefined inside an if case?

I'm trying to check if a string is only of one char, and I ran into this problem: LaTeX complains that \StrLeft in the comparison takes and additional argument: ! Argument of \@secondoftwo has an ...
6
votes
1answer
344 views

xstring character comparison and \meaning

\documentclass[pdftex,a4paper,12pt,oneside]{book}% \usepackage{xstring} \begin{document} \newcommand{\tmpa}{} \newcommand{\tmpb}{} \newcommand{\tmpc}{} \renewcommand{\tmpc}{abcdefg} \noindent ...
2
votes
1answer
151 views

Xstring dealing with macros

I wrote the \bib command to reference authors in my thesis not using numeric or alpha references of natbib. It copies a piece of text, cut the first 60 characters (the width of my page} and put it ...
5
votes
1answer
507 views

Generate labels using xstring and \Makelowercase

I am trying to write a command that allows me to reference a subsection with a generated label. The idea is that when I declare a step \step{Long Name With Many Uppercase Letters}, the generated ...
12
votes
1answer
287 views

Text being output when none should be

I am confused as to why the MWE below produces any black text. As the code is below, the output is: However, if you comment out the \IfStrEq line then it works fine and the black text goes away? ...
8
votes
3answers
1k views

Extract number from string and compare problem

I try to extract the year, month and day from a string and write different text depending on the given date. I thought I could use xstring and etoolbox, but I can'st get it to work. Here's the code ...
8
votes
4answers
3k views

How to cut a section title in the header

I redefine my headers as in the following MWE: \documentclass[12pt]{article} \usepackage{xstring} \usepackage{fancyhdr} \fancypagestyle{monstyle}{% \fancyhf{} % remove everything ...
0
votes
1answer
171 views

Getting an error when trying to use 'xstring' commands in my macro

When I try to compile the minimal example below, I get an error: ! Argument of \@xs@StrLeft has an extra }. <inserted text> \par l.33 \setInSCCF{abcdef} If I switch the ...
3
votes
3answers
300 views

Arguments expansion in IfSubStr

EDIT: Simplified question How can I make the following code print "Yes"? \IfSubStr{\textbf{AAA}}{AAA}{Yes}{No} Full question I'm playing with xstring's IfSubStr, but I don't really understand ...
5
votes
5answers
1k views

Process a string with replacing and splitting

I have an input string like "123-45" or "1-3-5" or "2-4; 6-8" where the minus signed should be removed. This is easy with the xstring package. \StrSubstitute{#1}{-}{} The next step is to split the ...
4
votes
3answers
791 views

Replace chars with xstring. Catcode problem

I try to do something like this (minimal example): \documentclass[]{article} \usepackage{mathtools} \usepackage{xstring} \newcommand{\foo}[1]{ \StrSubstitute{#1}{:}{\string&}[\fooo] ...
5
votes
1answer
145 views

Substituting strings only when not bounded by letters or numbers

Using StrSubstitute from xstring I can find and replace matches. For e.g.: \StrSubstitute{I like to eat fish.}{fish}{apples} gives "I like to eat apples." \StrSubstitute{Do you want to ...
3
votes
1answer
131 views

Splitting parameters in a macro

I have a macro like this: \newcommand{\listanimals}[1]{ Animals in the farm: #1. } So using \listanimals{pig / sheep / cow / duck / goat} will print: Animals in the farm: pig / sheep / cow ...
3
votes
1answer
217 views

Using xstring utilities on \ref*{…}

In the following code, I would like to use \StrGobbleLeft{\ref*{#1}}{2} so as to use n instead #n where the last formatting is used to number special footnotes for links. \StrGobbleLeft{\ref*{#1}}{2} ...
5
votes
2answers
216 views

\StrMid and \MakeUppercase problem

What's wrong with this: \documentclass{minimal} \usepackage{xstring} \begin{document} \newcommand{\cim}{c1095} \StrMid{\MakeUppercase{\cim}}{1}{1} \StrMid{\cim}{2}{100} \end{document} ...
5
votes
2answers
412 views

Feeding arguments to xstring macros

In Footnotes with automatic final period, the comment was made to provide the possibility to add a period . to a footnote conditionally, based on whether the footnote already has a period or not. I ...
5
votes
2answers
366 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 ...