{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 ...
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
263 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
47 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
147 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 ...
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
74 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
75 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 ...
3
votes
1answer
83 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; ...
7
votes
5answers
397 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 ? ...
4
votes
2answers
75 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 ...
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 ...
3
votes
2answers
189 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 ...
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
378 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 ...
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
376 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 ...
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: ...
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. ...
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 ...
9
votes
2answers
231 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
93 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: ...
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 ...
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
174 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 ...
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 ...
6
votes
1answer
216 views

How do I implement a string buffer in TeX?

I've recently learned how to create a macro to iterate over a token sequence using \afterassignment and \let in TeX. Currently, I'm trying to apply this to a tokenization macro (where "tokenization" ...
1
vote
1answer
134 views

Extra the word 'numberstyle' in listing

What's wrong with this ? I define listing style like below. \definecolor{codegreen}{rgb}{0,0.6,0} \definecolor{codegray}{rgb}{0.5,0.5,0.5} \definecolor{codepurple}{rgb}{0.58,0,0.82} ...
5
votes
2answers
102 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 ...
3
votes
2answers
324 views

Listings problem with quotes in a string

A single quote occuring inside a listings string seems to be interpreted as ending the string. Is there a way to avoid this from happening? \documentclass[12pt]{article} \usepackage[top=0.3in, ...
4
votes
2answers
154 views

numberstringnum or numberstring in lowercase

I have tried a lot to use the \numberstringnum and \numberstring macros but it appears incomplete or even do not appear on the text. So I tested in the female version, like below: ...