Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [strings]

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

3
votes
1answer
32 views

String operation creates error in pgfmathsetmacro

I am trying to reference the first character of a string within a pgfmathsetmacro, however, the macro \StrLeft from xstring, I believe, is not playing well with pgfmathsetmacro. Take the following ...
7
votes
2answers
149 views

How to define a comma separated list of arguments for includegraphics

I have a large set of pictures, and I want to apply predefined settings to each using the optional argument of the \includegraphics macro from the graphicx package. I would like to define the ...
2
votes
1answer
30 views

How do I stop matlab-prettifier thinking print strings are comments?

I am trying to put my code into a Latex document using matlab-prettifier. I am doing this by using \lstinputlisting[style=Matlab-editor]{Trap.m}. An example of Trap.m (a MATLAB file) is as follows ...
0
votes
0answers
39 views

Listings Keywords and strings inside comment have wrong style

I have a problem with listings package, I want comments to be all colored in DarkGreen, but keywords and strings inside them have different colors, can anybody help me? Here is my personal style: \...
4
votes
3answers
88 views

Trying to get \zap@space and \lowercase to work on string comparison

I am trying to do a non-case-sensitive check on two strings that may or may not have spaces in them. I have googled this and there is quite a lot of literature on either of these problems, but I can't ...
2
votes
1answer
54 views

Convert string to number

How can I convert numbers given as strings to "real" numbers? Consider the following MWE: \documentclass{article} \usepackage{datenumber} \usepackage{xstring} \begin{document} \newcommand{\tag}{\...
8
votes
2answers
256 views

Convert numbers to words, e.g., 111 = one hundred eleven, using the “Indian numbering system”

May I know if there is method for typesetting numbers to words using LaTeX. I have created an invoice in which I would like to convert the invoice amount to words. E.g., "1,23,456.00" should be ...
3
votes
2answers
57 views

Find the longest word in a string

Is there a simple way to get the longest word in a string? I would know how to program it in some other languages, but I'm afraid my latex kung-fu is not up to par... To make it clear, I want to make ...
3
votes
2answers
56 views

Formatting the text entered with commands in custom environment

I want to create some kind of a to-do list. Here is a simple example: \documentclass{article} \newenvironment{myEnv}[1]{% \begin{center}% --- #1 ---% \end{center} }{} \newcommand*{\...
1
vote
2answers
45 views

How did you mention a string(chain) properly [closed]

I am writing my thesis, in my document I have several paragraphs that mention character chains, How did you mention a string(chain) properly?, for example: Si termina con $G$ no puede Si termina con '...
2
votes
1answer
60 views

Latex3: Unicode (utf8) string, weird output with pdflatex

I want to store text that contains non-ascii characters in latex3 string variables. With xelatex and lualatex it works well but With pdflatex next mwe produces incorrect output. For legacy reasons ...
0
votes
1answer
58 views

String manipulation in xstring

I'm trying to make a string manipulation by using xstring package. Fore example \myparam equals to this: 1.1 Optimal solution of RNASP But string functions doesn't work. For example \StrLeft{\...
0
votes
2answers
73 views

how to redefine fancy headings and table of contents with variable strings

Requirements (A) create identical text to appear in both (i) the table of contents and (ii) the right header; (B) reduce the redundancy in my code so that I can pass the same string to both right ...
1
vote
1answer
39 views

\IfStrEqCase redefines #1

What is the meaning of #1, #2, etc in the optional parameter of \IfStrEqCase? This required me to use a ##1 instead of #1 within \pgfplotsinvokeforeach which I was not expecting. I would have ...
2
votes
1answer
99 views

Extract a substring from a Chinese string variable

Looks like the stringstrings package can do this: \substring{This is a string.}{1}{4} gives This, but it seems to be failed for non-ASCII characters: \substring{这是一个句子。}{1}{4} cannot give 这是一个. ...
2
votes
2answers
112 views

Lualatex: Change the colour of a specific character

This is similar to Change the color of capital letters and the MWE below is modelled on egreg's answer. It works up to the point of correctly changing the first character in the input string. What I ...
1
vote
2answers
74 views

Splitting Strings by Comma

I need to split a string by commas, and I haven't found an easy way to do it in xstring or xparse (although I may be missing something obvious). So if I say: \def\pleaseHelp{"I, am, confused"} What ...
3
votes
2answers
170 views

How to draw a line crossing two strings?

I want to type two strings in mono-spaced font and I want a line that make a subdivision of these two strings without altering how they are without this line. I know that it is a bit unclear but this ...
0
votes
2answers
57 views

How to convert datatypes?

I am trying to use datatools \DTLfetch to grab a real number from a database loaded from a .csv file, and then pass this numeric argument to \FPeval. Problem is that \DTLfetch always seems to return ...
14
votes
1answer
427 views

Which engines can compare strings expandably?

The pdfTeX engine introduces the primitive \pdfstrcmp for expandable string comparison, with the input itself fully expanded, for example \edef\foo{\detokenize{foo}} \ifnum\pdfstrcmp{\foo}{foo}=0 % ...
2
votes
1answer
69 views

Multibyte StrLen? (StrLen for chinese characters)

I am currently using \StrLen{#1} inside my \newcommand. This works flawlessly for any common string written in latin alphabet. "Hello" has string length of 5 for example. Problem is with chinese ...
5
votes
1answer
405 views

What is the difference between the two following structures?

First: \def\cs#1#2{00\fi\def\csa{#1}\def\csb{#2} \ifx\csa\csb} \if\cs{...}{...} Second: \def\cs#1#2{\fi\def\csa{#1}\def\csb{#2} \ifx\csa\csb} \if\cs{...}{...} I mean what role does 00 play in this ...
0
votes
2answers
217 views

Encoding of umlaute and special characters in \href links

I have a rather big project where I need multiple packages at the same time. I have problems in using "german umlaute" (äöü) and other special characters in \href links. Here is what I have: \...
4
votes
1answer
43 views

comparing substrings

I would like to get the following code running, but the second test fails with ! Argument of \@secondoftwo has an extra }. What do I miss? \documentclass{article} \usepackage{xstring,ifthen} \...
2
votes
3answers
112 views

Conditional tests on string variables in tikzmath library

Is it possible to test for strings in the tikzmath library? (E.g. if <variable>=<string expression> then foo) I tried a naive test and it returned this error: Package PGF Math Error: ...
5
votes
3answers
234 views

Array of strings as text for nodes in Tikz

I have a rather large number of nodes n1, n2,...,n41, all of them containing expresions like \textcolor{c}{blabla} and \large etc. It seem when storing all these texts in an array of the form ...
2
votes
1answer
109 views

How to pass literal comma as argument

I am using minted for code highlighting. I have defined a new minted file format, with the code \newmintedfile[plaintextfile]{text}{ ... breakafter=<values to break lines on>, ... }...
4
votes
1answer
48 views

Change sorting of authors in the index generated by Biblatex

I am looking for a way to change the way in which author (or editor) names are sorted in Biblatex-generated indexes. In French, we use accented letters such as é or è, which should be sorted with the ...
4
votes
2answers
207 views

Extract First Character (allowing for extra grouping)

I would like to extract the first character. Using xstring's \StrChar works fine for simple cases. However, when the paramter has an additional brace group, I need some expansion magic to get that to ...
2
votes
1answer
105 views

@string issues with current Biblatex/Biber: how can I stop my authors undergoing existence failures?

My bibliography set-up relies extensively on BibTeX strings. Until very recently - just now, essentially - this worked fine. Now, however, it works hardly at all. Here's a minimal example. I'm not ...
1
vote
2answers
33 views

Difference behaviour when passing a value or a macro

I am trying to fill in a form using the OCRB font. I need to add space after every digit in the amount. Below my command to do so: \newcommand*\giro@bvramount[1]{ \let\@tempa\relax \@tfor\@tempb:=...
5
votes
3answers
527 views

Why can't I compare a string read from a file with a predefined one?

I want to read a line of file and compare it to a predefined macro with the aid of \ifx. The following MWE shows my problem, I was expected to get Equal, but I get Not Equal. \documentclass{article} ...
1
vote
0answers
91 views

Concatenate string for \includegraphics

I'm trying to create a string (caseid) to which I can concatenate different string inside \includegraphics. \documentclass{article} \usepackage{graphicx} \begin{document} \begin{figure}[...
4
votes
2answers
348 views

Replacing characters in the argument - even within other commands

I need to replace all characters given as argument with other characters, doing some sort of transliteration. This answer provides a solution that works nicely with XeLaTeX and Unicode. ...
3
votes
1answer
71 views

Extract first character of string stored in macro using Expl3

I want to extract a set of n characters stored in a macro like this: \def\foo{bar} \extract{\foo}{1} prints: b using expl3. I have the following code: \DeclareExpandableDocumentCommand{\extract}{...
2
votes
2answers
134 views

Append strings to a variable and display them at the front of the document?

Not sure about this - but some ideas would be helpful, I wanted to know how to append strings, then at the end display the strings at the start? Is it possible? Any examples? For example, ... \...
2
votes
3answers
157 views

String multiplication possible in LaTeX as in Python?

I'd like to set a string multiplication in LaTeX in order to print n times a specific string or character. Just like in Python one would do : print('mystring' * 3) to get mystringmystringmystring. ...
1
vote
1answer
118 views

Concatenate string and `\today` macro

I'd like to use the \today command within a pathname. \usepackage{graphicx} \usepackage[iso]{datetime} \graphicspath{{./Figures_\today/}} This should point to ./Figures_2017-11-13/ What is the ...
0
votes
0answers
43 views

Insert String into another at specified position similar to printf with %s

Im looking for a way to insert the result of a command into a string at a specific position. Background is that I want the hyperref package to link "Figure 1.2" and not only the "1.2" like when I'm ...
1
vote
1answer
116 views

Lualatex, insert text with newline

I have some trouble to understand why I can't insert newlines in lua code that is inserted in a tex document. If I do so, I've the error ! LaTeX Error: Missing \begin{document}. MWE: file test.lua: ...
0
votes
1answer
129 views

How does one use pdf@strcmp in the pdftexcmds package? [duplicate]

I am trying to compare two strings with pdf@strcmp but I get the error: ! Undefined control sequence. <argument> \pdf @strcmp{abc}{abc} l.6 \section{\pdf@strcmp{abc}{abc}} ...
3
votes
3answers
135 views

How to replace some of text, by other some of text

I want to replace some of text, by other some of text! See my example: \begin{document} This (1) is (2). (1: book) (2: good) \end{document} I want to see this output in PDF: «This book is ...
1
vote
3answers
303 views

How to convert string to command?

How can I run command by using string? for example, I have created new command: \newcommand\footn{\footnote} Now, I don't want to use this command directly, I want to use @footn{*} instead this: \...
1
vote
1answer
123 views

Issue with “string type” format column in pgfplottable

Using pgfplotstable library to define a table from a data file containing numeric and alphanumeric values, I get this error "! Package PGF Math Error: Could not parse input 'B' as a floating point ...
1
vote
1answer
102 views

expand string array in loop with label

I would like to expand one string array in a short metafun loop. Each box should be labelled with the appropriate string ("classicism", "Lumières", "romanticism"). How can I make the label function, ...
6
votes
6answers
548 views

How to replace characters from jobname?

I have a tex file with name Chap-Name_of_Section.tex and I running pdflatex on it. I want to set the title of my document automatically according to the file name. This could be done using \jobname. ...
2
votes
1answer
156 views

Replacing a substring from a command

I have a problem where I seem to be unable to replace a string that is the output of a command. In my document I call the \outerfunction with an argument that is actually a list of key/value pairs. (...
2
votes
2answers
43 views

substring with calculated end position

I have a string and I would like to use only the first part of the string up to a specific position. So I wrote the \stringpart command using strinstrings' functions. The position of the searched ...
2
votes
1answer
112 views

How to replace semicolon with comma for pdfkeywords in hyperref

From an external file I get a list with keywords separated by ;. Since hyperref only works with keywords separated by , I need to replace the semicola. Following MWE works for text but not for ...
1
vote
0answers
65 views

Use \verb inside \seqsplit

I need to use the \verb command inside the \seqsplit command. The compiler warns me when I insert \verb inside \seqsplit. How can I do? thank you all EDIT: \seqsplit{\verb |#####|} Error: ! ...