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

5
votes
3answers
69 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
20 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
170 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
70 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
28 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
45 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
48 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
38 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
118 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
89 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
97 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
73 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
104 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 ...
4
votes
1answer
73 views

Centering \dot in a symbol macro (\listofsymbol)

I was trying to achieve the results of get a variable listed in listofsymbol's generated list, when called with a -dot suffix. If was trying also to find a way to center dot in variables with ...
2
votes
1answer
34 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
200 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 ...
6
votes
4answers
123 views

Using MakeLowercase and StrSubstitute together

I'm using LaTeX and have a string that I want to remove underscores from, and convert to lower case (in either order). The individual steps work: \MakeLowercase{AB\_CD} \StrSubstitute{AB\_CD}{\_}{} ...
10
votes
1answer
144 views

Why can't I expand \ref*{} as a string?

In the following code, if you change \def to \edef the code crashes. Nor can you perform normal string operations or tests. Removing hyperref (and replacing \ref* with \ref) works fine with \edef. ...
3
votes
0answers
63 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
84 views

How to modify Bibtex URL tags in Latex?

I want to cut the URL tags defined in a Bibtex file. For example I want to crop the prefix "mailto:" so that it won't be shown. But the hyperlink still has to contain it. The following command does ...
32
votes
6answers
2k 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 ...
4
votes
2answers
77 views

xmakefirstuc combined with MakeTextLowercase

I am trying to convert a string as in the example, with all lowercase characters except the first. However, xmakefirstuc does not like me that much. Here's my MWE: % arara: pdflatex ...
2
votes
1answer
67 views

Retrieving text from a “database text” file

I refer to my question and the solutions in String comparison in \ifthenelse I hope I can make my question clear enough, I am not a technician. I use a kind of database file (simple text file) with ...
9
votes
3answers
151 views

Generating a table based on a list and a number of columns

Sometimes a table is used to compact a large number of items. Example: a b c d e f g h j k l Instead of listing all items separately. We want to define a command that eases the implementation of ...
3
votes
1answer
89 views

includegraphics and xstring package

I would really like to do something like the following: \includegraphics{\StrSubstitute{No Spaces}{ }{}} However, this gives me an Undefined control sequence error. I saw some other posts about ...
3
votes
1answer
86 views

makeidx, xstring, forloop and utf8 conflict

I'm using Danish characters in strings that I split with \StrCut from the ×string package and use within a \forLoop from the forloop package. The result is not good. Consider this small example: ...
4
votes
2answers
88 views

Replacing substrings by linebreaks

I have a LaTeX document with several authors that I enter like \author{First Author \& Second Author \& .... In some places in the document I want to print these authors with a linebreak ...
6
votes
1answer
71 views

Substitute string in subscript

I want to define a command to shorten formula like this a^1,\cdots,a^n, using a placeholder (-) instead of index, the code is \usepackage{xstring} ...
4
votes
1answer
105 views

Extract from a token containing a list with math content

I have a token which contains a list consisting of: a date in YYYY-MM-DD format, followed by a colon, and some text which may contain math. The text will consist of a sentence or two (i.e., no ...
2
votes
1answer
170 views

Underline/Bold/Highlight multiple names in a bibliography

This is a variation of the question posted here: Now I want to highlight multiple names in a bibliography. Here is the erroneous solution that I tried. \documentclass[11pt,letter]{article} ...
3
votes
2answers
121 views

Generate comma separated list with some non-empty strings

I'm trying to generate a comma separated list that uses strings that may or may not be empty. For example \mylist{\stringA,\stringB,\stringC} would expand to A, C if B is empty or B, C if A is empty, ...
2
votes
1answer
154 views

gitinfo (xstring): tag info does not work because of “tag:” before version number

I'm making the switch from subversion to git, and I'm quite happy with the gitinfo package. The only thing I cannot get to work is to show a version number from the tag. I have identified the ...
2
votes
2answers
118 views

How do I use IfStrEqCase within a siunitx command?

I am having trouble using \IfStrEqCase from xstring inside \num from siunitx: \documentclass{article} \usepackage{xstring} \usepackage{siunitx} \newcommand{\bla}[1]{% \IfStrEqCase{#1}{{a}{1}% ...
8
votes
1answer
130 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: ...
6
votes
3answers
163 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 ...
2
votes
1answer
176 views

Latex: splitting/processing strings inside a latex command

Let's say I have \ingredients {% \unit[375]{g} & Farina 00\\ \unit[250]{g} & Burro\\ \unit[3]{g} & Sale\\ 1 & Limone } (you got me: I'm dealing with xcookybooky) ...
5
votes
2answers
143 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 ...
4
votes
1answer
187 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} ...
8
votes
2answers
142 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 ...
4
votes
1answer
131 views

Loading file after converting to ASCII characters

I am writing a document on phonetics using the media9 package to include pronunciations of some of the words in the document. The words that are to be pronounced are in Danish, and thus their ...
5
votes
1answer
192 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
105 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} ...
2
votes
0answers
205 views

Why can't I get a conditional command to work in a macro invoked within a tikzpicture?

I wanted to create a macro that can be invoked in the middle of a tikz path and behave differently, conditional on one of the arguments. Here is an example document: \documentclass[a4paper]{amsart} ...
4
votes
0answers
132 views

How to include part of an external git hash as text inside a document?

This is my first time asking a question on a site like this. Please tell me if I should do something differently, thanks! I want to include a short version of the latest commit hash from git as a ...
8
votes
1answer
142 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 ...
9
votes
3answers
227 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 ...
2
votes
1answer
92 views

How to use \StrBefore in \chapter with optional argument

I want to trim the chapter titles in toc up to first dot. \documentclass{book} \usepackage{xstring} \newcommand{\chap}[1]{% \chapter[\StrBefore{#1}{.}]{#1} } \begin{document} \chap{Some title. ...
4
votes
3answers
887 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]{ ...
7
votes
1answer
140 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 ...
11
votes
2answers
202 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 ...