{strings} are sequences of characters (most commonly literal constants).

learn more… | top users | synonyms (1)

5
votes
3answers
100 views

Check occurrence of a macro inside another macro

With the substr (or xstring) package you can, of course, identify whether a control sequence contains some text string: \documentclass{article} \usepackage{substr} \def\somecontrolseq{some silly ...
7
votes
5answers
396 views

Command to count characters in a specified string

Is there a way to count the number of characters in a specified string? Suppose I had the following code. \documentclass{article} \newcommand{\numchars}[1]{\noindent The string ``#1" has ? ...
3
votes
3answers
69 views

How can I embed xstring commands (with commands as tokens) within other xstring commands?

I'd like to manipulate strings. The following hello_en.txt should become hello. This is related to, and quite possibly a duplicate of, Command doing the same job as StrBefore but being expandable. ...
1
vote
0answers
17 views

How to split a long string in a variable? [duplicate]

I would like to split a long string (as in the example below) when this string is in a variable: \documentclass[a4paper]{article} ...
3
votes
1answer
43 views

Can Luatex (or latex) detect presence of non-latin1 character in string?

Using Luatex Unicode, I would like to detect whether or not a string contains any characters outside the Latin-1 set. If it does, then I would like to fork. Something like this: ...
7
votes
2answers
262 views

How to repeat over all characters in a string?

I have a command that formats a single character, let's call it \d{}. (In my case, \d{} adds a dot under a Chinese character, as this is the custom to emphasize Chinese texts). I want to define a ...
1
vote
1answer
45 views

double quote charater (’"’) with listings create problem

I have don't know how to fix the double quote character (’"’) with the listing package. Listing get this as the beginning of a string but it is not. Here is the colored minimal example to show the ...
2
votes
1answer
40 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 ...
2
votes
1answer
33 views

Rearranging \cite arguments

I have the following requirement for my thesis: If I cite multiple citations, I should cite my papers first. The names of all my papers start with “my:”. So I want to define a new command that ...
1
vote
1answer
22 views

\ForEachX and string concatenation

I'm writing a class where I have an arbitrary number of strings that I'd like to concatenate, then loop over and typeset using \ForEachX from the forarray package. If I define a command to add to a ...
1
vote
2answers
37 views

How do I define a list of strings with the babel package and the ngerman option?

I try to make a pie chart, but can't get the labels right: This is the MWE: \documentclass{article} \usepackage[ngerman]{babel} \usepackage{tikz} \definecolorseries{colorser}{rgb}{last}{blue}{green} ...
3
votes
1answer
93 views

List of strings for tikzpicture

at first my MWE: \documentclass{article} \usepackage{tikz} \begin{document} \def\johnlist{{ala},{bla},{cla}} % \def\johnlist{2,3,5,7} %This instead of the line above works... \begin{tikzpicture} ...
4
votes
2answers
145 views

Replacing braces in strings

I know I should probably not want to, but say for the sake of discussion that I wanted to remove braces from a string for some purpose (background, now obsolete). From its package description, ...
1
vote
1answer
44 views

Dealing with braces in filenames for graphicx

For the purpose of managing a large reference document with many included files, I include links to these files in the margin. Broken down to an MWE, this is what I do: \documentclass{article} ...
1
vote
0answers
32 views

How to split a string to figure float with figure name, label and caption?

I am struggling with a shorthand macro that converts a string to a figure. At the end is a working, but unstable version what I am trying to do. The goal is to parse make a command (or macro) like ...
7
votes
2answers
136 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 ...
2
votes
1answer
57 views

Bibliography string 'by' undefined in Canadian

I use babel with the canadian language, and biblatex-chicago. If I use a @inbook reference with a bookauthor field, I get the following error: Bibliography string 'by' undefined at entry 'smith' on ...
0
votes
1answer
33 views

Using fully expanded result as a simple string (with citet and \IfSubStr)

I am breaking my head with that problem, without finding anything that could help on Internet : The initial problem is that I write an essay in French but I need to include some articles written in ...
2
votes
1answer
19 views

Compare authors of two natbib references

I am trying to find out whether two references have the same author with natbib. But I seem to be unable to get basic string comparisons working. Without a deeper understanding, I have tried ...
1
vote
1answer
73 views

Wrong string color in embedded code

My problem is that when I use the correct quotation marks ``'', lstset does not recognize strings in my code and thus does not color-code them. When I use standard double quotes "", the leading ...
4
votes
1answer
74 views

Extract the last word from a sentence stored in a variable

I want to extract the last word of a sentence stored in a variable, e.g. \thevariable. Here is the minimal example. \documentclass{article} % Function to extract the last word of a sentence ...
0
votes
1answer
47 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 ...
23
votes
3answers
919 views

Change the color of capital letters

Is there a way to define a command that changes the colour of any capital letter in an input string? Most of the results I find when I type "LaTeX string capital" are results about capitalizing the ...
3
votes
1answer
82 views

Formatted number printout in LuaTeX?

I have this code that I copied from What is a simple example of something you can do with LuaTeX?. \documentclass{article} \usepackage{luacode} \def\score#1#2#3{% \directlua{ s1 = #1; ...
4
votes
2answers
74 views

String comparisons not working with textgreek

Following the solution from this question as a guide - Are there any "if" commands like "\ifnum" in LaTeX? - I have setup a newcommand to perform a string comparison. ...
5
votes
1answer
41 views

Replacing an id (integer) with a string?

I have a tex document that contains sections that are automatically generated. These sections have strings that are observation IDs. I would like to have latex replace all occurrences of an ID with ...
3
votes
2answers
162 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 ...
3
votes
2answers
188 views

Deleting duplicates from a comma-separated list of strings

This is a followup to Difference in compilation time between two slightly different versions. As became obvious when asking that question, the speed of that compilation is seriously affected by the ...
4
votes
4answers
111 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 ...
2
votes
1answer
80 views

Define an expandable function for comparing a token list to a string in LaTeX3

In LaTeX3, I could define a function for comparing a token list to a string \cs_generate_variant:Nn \tl_if_eq:nnTF { V } \cs_new_nopar:Npn \module_compare:n #1 { \tl_if_eq:VnTF \g_some_tl { #1 ...
7
votes
2answers
375 views

How to split input string in a LaTeX command?

I would like a new command: \myfunc{string}, where string is something like: "a,b,x,y,x" and the effect of the command should be the following: \func{a}\func{b}\func{x}\func{y}\func{x}, where \func{} ...
0
votes
0answers
41 views

Different bibtex tags content enclosing and string concatenation

I had noticed strange (in my opinion) behaviour of string concatenation in bibtex entry. I tested three different examples: @string{abc={ABC}} @string{def={DEF}} @string{abc="{ABC}"} ...
3
votes
1answer
107 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 ...
7
votes
4answers
2k views

Logical String Length

How do I do a conditional 'if then else' statement, based on length of string being greater than (or less than, or equal) a specified value. For example, something Like \def\mystring{XYZ} ...
0
votes
0answers
32 views

How to load input file with given starting string but unknown end?

In the directory of my latex source there are input files: input_01.tex, input_02.tex, etc. It is very easy to load them with a for cycle. But how to load them if their names are: ...
5
votes
3answers
375 views

LaTeX: Access every character of an string variable

I'm using variables to create strings in that way \newcommand{\myText}{2014/12/20} \myText{} This works great. Now, I can to access every single character of this string (length is 10), because in ...
5
votes
1answer
217 views

Biblatex abbrevation for no author/editor/year/etc. in alphabetic style

I use an alphabetic citestyle with biblatex. Sometimes I have entries where no author or editor or year is given. For example there is often no editor for a proceeding. At the moment I leave the entry ...
0
votes
0answers
46 views

Strip control characters from token

I've added a hook to lstlisting to do some special highlighting. Now I've got it to highlight %-prefixed variables just fine, but I'd like to handle the special case "%this" in another way. ...
1
vote
0answers
19 views

Bibliography string 'print' undefined [duplicate]

I use biblatex and a special fonencoding for the cyrillic alphabet. Everything works fine, only the bibliography prints an additional, unwanted string 'print' at the end of each item. Here's my code: ...
9
votes
2answers
229 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 ...
3
votes
1answer
92 views

Expand arguments in string substitution macro

Rewritten as minimum non-working example: \documentclass{article} \makeatletter \usepackage{xstring} \usepackage{xparse} \newcommand\textfromcase[1]{% \IfEqCase{#1}{% for the purposes of this ...
1
vote
1answer
54 views

A command for making a string of characters [duplicate]

How can I make a command (or is there an existing one?) which takes two arguments: 1) character type 2) N (count) and puts N number of characters side by side? \newcommand{\foo}[2] { % sample: ...
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 ...
8
votes
5answers
425 views

A command which concatenates a string an arbitrary number of times

I'm trying to define a command \repeatstring{#1}{#2} which repeats the string #2 #1 times. Here is what I tried: (it is based on what I found in How to concatenate strings into a single command?) ...
5
votes
2answers
91 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 ...
8
votes
2answers
173 views

Creating bullet-list from string with delimiters

I want to create a bullet list from a string with delimiters in it. The delimiter in my example is | Example string: This is|A bullet|List from|A string I want to get that to become a bulletlist ...
17
votes
4answers
614 views

Extract the numerical and non-numerical portion from text

I would like to extract the leading number and subsequent text from a string. I have an idea of using the xstring package to gobble characters from the right until I end up with a number or an empty ...
8
votes
1answer
79 views

Defining a reusable string from within an environment

I write documents that rely heavily on the 'enumerate' environment. I'd like to turn any particular item from within that environment into a variable that I can use elsewhere. The idea is to ensure ...
2
votes
1answer
2k views

ifthenelse equal string comparison fails

I am trying to fix some problems with the accessibility.sty package from www.babs.gmxhome.de There is one string comparison which always results to false, i.e. the language code definition will not ...
14
votes
2answers
711 views

String comparison in \ifthenelse

I want find a certain line of text in a data file cities.txt: A;London B;Berlin C;Paris with the xstring and [xifthen][2] packages: \documentclass[12pt, a4paper]{article} \usepackage{xstring} ...