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

29
votes
5answers
1k views

Censoring Curse Words with Grawlixes

Suppose that I would like to censor a curse word <word> using grawlixes, e.g. "What the #@$! are you doing?!" How can I define a command \censor such that \censor{<word>} results in a ...
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? ...
11
votes
2answers
166 views

How to process a list and ignore spaces?

This question is part of a new package: metrix. Typeset metric/prosodic symbols standalone and above syllables. I’m wrinting a new package and I need to process a list (using etoolbox at the ...
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 ...
10
votes
2answers
117 views

Is it possible to use \index{\command} inside a \DeclareDocumentCommand?

So I've been writing a book of sorts where I've used xparse to create some commands and environments. Now, when the thing is almost done, I realised a index would be great to have! One of the ...
9
votes
3answers
158 views

Command doing the same job as StrBefore but being expandable

I am looking for a command allowing me to get 3 as output if the input is 3.2. \StrBefore{3.2}{.} works fine for this purpose but is not expandable and I need to call it in another macro inside a ...
9
votes
1answer
176 views

Manipulate title field's strings in biblatex

I need to take the first string (considering First~Second a single string) from the title field from anonym entries and: Format this first string differently from the rest of the title, e.g.: ...
8
votes
3answers
147 views

xstring command in renewcommand

I'm trying renew \texttt command with condition on ending . or ,. But after making this: \usepackage{xstring} \let\OldTexttt\texttt \renewcommand{\texttt}[1]{% \OldTexttt{\hspace{0.4em}#1}% ...
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 ...
8
votes
4answers
217 views

choose from a list with xstring

I want a command that does the following: \variation{1}{aaa;bbb;ccc} ----> aaa \variation{2}{aaa;bbb;ccc} ----> bbb \variation{3}{aaa;bbb;ccc} ----> ccc The string in the second input can ...
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 ...
8
votes
2answers
100 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 ...
8
votes
2answers
250 views

StrSubstitute for multiple replacements in a loop?

I am trying to replace multiple keywords using \StrSubstitute inside a loop using foreach - but unable to accumulate all the results. The result of each \StrSubstitute call is getting lost inside the ...
8
votes
1answer
77 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: ...
8
votes
1answer
83 views

Undefined Macro in Package xstring

I have a very basic problem. I am trying to use the xstring package in a Latex document and I keep getting the following error message for an undefined control sequence: (c:/Program Files ...
7
votes
2answers
333 views

LaTeX macro for Wikipedia article link

I'd like to create a LaTeX macro that will auto-create a link to a Wikipedia page for me. \usepackage{xstring} \usepackage{hyperref} % replaces the whitespace with '%20' ...
7
votes
2answers
143 views

Trouble using xstring to edit input parameter strings

I am trying to use \StrDel to modify a parameter to use within a command. For example, say my .tex file contains: \command{Word Anotherword} and the .sty file I reference contains: ...
7
votes
1answer
93 views

Count the number of references containing substring in field

I have several references in a document. I'd like to display some statistics regarding the references - for example, citations with author Smith, citations between year xxxx and yyyy, citations ...
6
votes
3answers
84 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 ...
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} ...
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 ...
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 ...
6
votes
2answers
100 views

xstring substitution with font commands fails in error

I want to substitute some spaces with normal font \dots in between name parts typeset in \ttfamily. Below example works except for the commented part which fails miserably with the error: TeX ...
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 ...
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 ...
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 ...
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
83 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 ...
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
140 views

\uppercase does not work with \IfSubStr?

I'm using \IfSubStr macro of xstring package to decide if user given options contains some letter and if they do I take some actions. I want case independent test on whether user options contain ...
5
votes
2answers
77 views

Passing value to \bibleverse

Please help me to find out, how to pass a value to a command, which has additional arguments enclosed in (...). \usepackage{bibleref} \usepackage{xstring} \begin{document} \bibleverse{Gen}(9:9) ...
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 ...
5
votes
1answer
52 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} ...
5
votes
2answers
76 views

How to choose from a list for using result in \ref?

Recently, in choose from a list with xstring, Geoff was asking about defining the command \variation that does the following: \variation{1}{aaa;bbb;ccc} ----> aaa \variation{2}{aaa;bbb;ccc} ...
5
votes
1answer
93 views

\IfSubStr does not work when used as parameter of another macro

It seem that if macro \IfSubStr from package xstring is used as parameter it is not expanded like other macros are. Here is minimal demonstration: \usepackage{xstring} \newcommand{\copyArg}[1]{#1} ...
5
votes
2answers
154 views

Transforming string into tabular row

Trying to have a command converting a string into a (tabular) row, where each cell of the row is (a function of) each character of the string. (\tilerow is my attempt, \tiletext is just for ...
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 ...
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 ...
5
votes
1answer
100 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
144 views

How to best split long strings?

I would like to do a simple \StrSplit (from the xstring package) on a string I have, however, the string in question may contain a \par, and it appears that \@xs@StrSpl@t@@, which I can only imagine ...
5
votes
0answers
1k views

MikTeX can’t find xstring [closed]

I’m not using MikTeX myself but someone I developed a class for. And it seems like there’s a problem with xstring. The following MWE compiles fine with my TeX Live 2012 but MikTeX (on Win 7) can’t ...
4
votes
3answers
406 views

Misplaced \omit and \multicolumn in \IfEqCase

I have the following code with a command that creates rows for a tabular: \documentclass[letterpaper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{xstring} \newcommand*{\condrow}[2]{ ...
4
votes
3answers
790 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] ...
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 ...
4
votes
2answers
102 views

How to test if a given reference belongs to a list of labels?

This question is a prolongation of my previous question How to choose from a list for using result in \ref?. I got really good and interesting answers. Unfortunately I can not implement them for my ...
4
votes
2answers
628 views

Upright bold greek with condition in math mode

Good day! I googled the whole stackechange, but was not able to find the answer. I'm quite new to Latex, so my approach is not proper. I try to define a macro, that should format greek letter as ...
4
votes
2answers
154 views

controling padding using the xstring package

in order to pad some text with a predefined padding, im using the xstrings package my current code is \documentclass{minimal} \usepackage{xstring} ...
4
votes
1answer
119 views

Expanded StrSubstitute

I am trying to use \StrSubstitute, but what I want is to expand it all the way to get the result string. \StrSubstitute{Řepa}{Ř}{Rzzz} then i use it with % somehow define \a as the result string ...
4
votes
1answer
89 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} ...