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
26
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 ...
6
votes
2answers
55 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 ...
3
votes
1answer
46 views
How can by macro as parameter of other macro?
\StrPosition{AQ2 K863 1065 J1065}{ } give 4
\StrMid{AQ2 K863 1065 J1065}{1}{4} give AQ2
\StrMid{AQ2 K863 1065 J1065}{1}{\StrPosition{AQ2 K863 1065 J1065}{ } } i want AQ2
but give error message.
4
votes
1answer
53 views
Check for special character in verbatim environment
I would like to substitute a > in the beginning of each line of a Verbatim environment with another character. Consider:
\documentclass{article}
\usepackage{fancyvrb,xstring}
...
2
votes
1answer
82 views
Cutting string with formula or cite
I am trying to define a macro that would take a string and paint its ending, for example:
\def\paintString#1{%
\saveexploremode%
\exploregroups%
\textcolor{white}{\StrGobbleRight{#1}{5}}%
...
8
votes
3answers
92 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}%
...
4
votes
2answers
101 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 ...
1
vote
1answer
78 views
xstring macros inside foreach
I don't really understand what is the problem here, but I guess it has to do with expansion and fragile macros since when I do the same outside of \path it works.
Code:
\documentclass{article}
...
8
votes
1answer
150 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.:
...
0
votes
0answers
48 views
Usage of \IfEndWith and \StrGobbleRight Inserting Spaces [closed]
2013-03-06: Update:
It seems that there was a recent update to xstring which resolved this problem. Just updated all packages and the MWE below now correctly produces:
It seems as if I am ...
3
votes
1answer
77 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 ...
5
votes
1answer
68 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
88 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
1answer
97 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 ...
7
votes
2answers
239 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'
...
3
votes
1answer
80 views
spreadtab out of memory using STCopy and macro
The following code fills a table using \STCopy. It generates an 'out of save size error'e [MiKTeX 2.9].
If I make the table smaller (by commenting a row out) or remove the max call (and use only the ...
2
votes
1answer
177 views
XeLaTeX - Devanagari page numbers in \tableofcontents [duplicate]
Possible Duplicate:
How to get devanagari numerals in latex or xetex
I am using XeLaTeX (XeTeX, Version 3.1415926-2.4-0.9998 on TeX Live 2012/W32TeX). I want Devanagari (Indic) page ...
5
votes
0answers
828 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
2answers
91 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
2answers
89 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 ...
5
votes
2answers
68 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} ...
8
votes
4answers
166 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 ...
3
votes
2answers
147 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
224 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
96 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
175 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
99 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
275 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 ...
0
votes
0answers
381 views
Is there a way to use a global variable? [closed]
I am using multimarkdown to produce LaTeX files. I decided to create a series of templates and use a simple /def/dtype in my document to decided which template to use. The header produced would be ...
5
votes
2answers
265 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
333 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
179 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 ...
5
votes
1answer
232 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
128 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
311 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
258 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
671 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
2k 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
144 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
216 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
643 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
517 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
129 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
119 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
171 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
175 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
294 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 ...
4
votes
2answers
288 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 ...