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

learn more… | top users | synonyms (1)

0
votes
0answers
17 views

Latex lstlisting: stringstyle not working

I defined my own language Drools and I want that the words between "" have the color red. I used stringstyle to do that but this doesn't work. Am I forgetting something because I couldn't find any ...
3
votes
2answers
39 views

How do I perform an expandable string comparison?

I need to perform a string comparison (string equality). If the macro is non-expandable (e.g. contains \def or \let), it causes problems in the place where it is used. I tried using \ifthenelse from ...
7
votes
3answers
77 views

String comparison

\documentclass{article} \usepackage{xifthen, xstring} \newcommand{\IfOne}[3]{ \if\TokenIsIn#1 #2 \else #3 \fi } \newcommand{\IfTwo}[3]{ \ifthenelse{\equal{\TokenIsIn}{#1}}{#2}{#3} ...
0
votes
0answers
17 views

Splitting volume name in bibtex

I would need to check the content of the "volume" field when reading a bibtex entry, and in case split it into two parts. For instance, I have in the bibtex file: journal = "Phys. Lett.", ...
8
votes
2answers
817 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{} ...
1
vote
1answer
25 views

converting file: url to path

I am creating LaTeX files using a template engine. The problem I am running into is that the template engine is designed for generating web pages and generates URLs for external files, such as images. ...
4
votes
2answers
48 views

How to use \nameref with xstring package to check string length

I need to measure a number of characters in string, that I returned from label through \nameref command. Here is my MWE: \documentclass{article} \usepackage{hyperref} \usepackage{xstring} ...
4
votes
1answer
41 views

Open and decode

I use \pato{R}{2015}{07}{27}{A}{1}{4}{black} to \input my sub-archive R20150727A1-4.tex, and it works for me. How can I perform a new command, say \otap{R20150727A1-4}, that decode and assign for ...
1
vote
0answers
21 views

`string replace` before plotting

The package pgfplotstable defines a key string replace* that can be used to replace strings inside a typeset table (in \pgfplotstabletypeset); for instance (quoting from the manual) ...
4
votes
4answers
167 views

Expandable macro with loops and advanced string functions?

This might be a very basic problem (as a follow-up to this question) but I cannot figure out how to do it: I need a macro \mycmd{sometext} that yields a string depending on the first character of its ...
9
votes
1answer
157 views

What packages provide text/command substitution for LaTeX, XeTeX and LuaLaTeX?

I am aware of the following: xesearch - Allows both text and command substitution. Only for XeLaTeX Simple example: \usepackage{xesearch} \SearchList{list1}{Hello}}{hlw} Any time "hlw" is ...
2
votes
1answer
48 views

Truncate parameter before newline

I want to truncate (cut/shorten) a string that contains newline (\\ or \newline) in such a way that only the first line remains. My problem is, that I use the todonotes package and have command ...
2
votes
1answer
18 views

Passing length in form of a string instead of measure [duplicate]

I'd like to pass a measure of length in form of a string, i.e. \setlength{string} or \setlength{'string'} instead of \setlength{2.5cm} I seem to remember seeing something like that somewhere ...
1
vote
1answer
29 views

hypertarget with accents

with XeLaTeX (so native Unicode input), I would like to create a macro which, from a string, will create an hypertarget which anchor's name contain string. \documentclass{article} ...
6
votes
2answers
103 views

Use \item as a string in comparison

I wish to design a convenience command \lazycmd that works like this (simplified version): \newcommand{\lazycmd}[1]{% ... } % Use case 1. \lazycmd{ \item one \item two } % Use case 2. ...
4
votes
1answer
546 views

Compare strings

I have some troubles by comparing strings in my beamer theme. I would like to compare the "techno" argument with a string (iOS, Android, Java,...): if techno =="iOS" logo_path = "some_image" else if ...
10
votes
5answers
6k views

How can I draw oval circle around a string?

How can I draw oval circle around a string? For example, when I have "1,3,4,6", how can I put them in a circle?
0
votes
1answer
51 views

Biblatex abbrevation for no editor second try

Referring to my previous question I now try to solve the problem with the missing editor for a proceeding or inproceeding entry. So if I write the command \noeditor into the field editor one should ...
3
votes
1answer
67 views

biblatex: string manipulation after processing of bibtex @STRING

I am using biblatex 3.1 in conjunction with some BibTeX (.bib) files. These files begin with @STRING macros like @STRING{CUP="Cambridge University Press"} and contain entries that have this form: ...
1
vote
1answer
114 views

Convert numbers in string to string

I store some strings in a variable \def\nomVAR{A12Z4E} and I want to create some other command using the content of \nomVAR. LaTeX doesn't accept to declare variable with number in its name. So the ...
5
votes
1answer
36 views

How to get a customized number of decimal places in tex.sprint / directlua / qrCode?

The number of decimal places is "9" in the following example: string.format("\%0.9f", X). How can one achieve the replacement of the fixed "9" decimal places with "NumberOfDecimalPlaces" (in ...
8
votes
3answers
353 views

Changing the alignment character (default: &) in tabular-like environments

I want to define a simple tabular environment that treats spaces as the column separators. So something like a b c d should be treated as a & b & c & d. I've tried using \StrSubstitute but ...
3
votes
1answer
85 views

Problem defining a string column with PGFPlotsTable

First, I am fresh new with the PGFPlotTable package! I have the following CSV file that I would like to plot in a LaTeX table: ...
1
vote
1answer
79 views

Is it possible to get rid off of { and } in the definition of a command?

My purpose is to write simple commands that put graves and other accents symbols above Greek letters. I am facing the following problem: Let say \grave{i} puts the grave symbol above I (for example: ...
4
votes
2answers
34 views

Problem with \IfSubStringInString and special characters

It seems that IfSubStringInString has a problem if the sub string contains umlauts or other non-ASCII characters, as is illustrated by the following example: \usepackage[utf8]{inputenc} ...
3
votes
1answer
50 views

Remove \par from string

I have to put a string in various places of a book. This string is stored in a macro \newcommand{\subtitle}[1]{% \newcommand{\thesubtitle}{#1} } \subtitle{The quite long \par subtitle} Long ...
2
votes
1answer
51 views

Case Sentence With xstring

I have a LaTeX document that gives me the following error: ! Argument of \@xs@IfStrEq@@ has an extra }. The document is as follows: \documentclass{article} %PAQUETES ...
20
votes
3answers
27k views

\uppercase in \newcommand

I tried to use \uppercase in \newcommand: \newcommand\universidad{My University} \newcommand\Universidad{\uppercase{\universidad}} When I use this I get My University and not MY ...
2
votes
2answers
45 views

Replace \\ command only within \chapter

I am converting .tex files to .epub. I need to selectively replace the string "\\" ONLY within chapters command to a single blank space. example: \chapter{My title \\ on two rows} becomes: ...
3
votes
1answer
69 views

Need help for macro to split a string and put the substrings into temp variables

I have something like this: \documentclass{article} \newcommand*\tableData[2]{string1,string2,string3}{string4} \newcommand*{\String1}[1]{#1} \newcommand*{\String2}[1]{#1} ...
4
votes
1answer
96 views

Carry out substring replacement on variable's contents

Say I have a variable that contains some non-plain text, for instance \def\var{Caro \textit{et al.}}, and I want to make a substring substitution of Caro for \underline{Caro}. If I try to follow the ...
6
votes
4answers
223 views

Automatically removing, after compilation, parts of text enclosed in certain strings

Is it possible to create a macro, such that everything that is between the string composed of the characters "whitespace", "{", "L" and the string composed of "L", "}", "whitespace" is not displayed, ...
2
votes
1answer
72 views

Treat environment content as string, replace substrings and interpret afterwards

I would like to define an environment which "parses" its content and changes it before displaying it. An additional difficulty comes because I also need to replace whitespaces. The more flexibility ...
1
vote
1answer
122 views

String diagrams in monoidal categories

I'm writing a paper which contains a chapter on a certain kind of monoidal categories (spherical, that is) and I would like to include the usual graphical calculus for morphisms. In particular, I'm ...
7
votes
1answer
200 views

LuaLaTeX: How to use a \char directive inside a string.gsub function?

Consider the following MWE: % !TEX TS-program = lualatex \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=NoCommon]{Latin Modern Roman} \usepackage{luacode,luatexbase} ...
3
votes
1answer
81 views

Character replacement in unicode string

I need a command to replace (erase) the characters · and | from a string. Consider the following naive code: \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} ...
2
votes
5answers
227 views

Package to test whether a string is in a list

Is there a package that provides a command for testing whether a string is in a list? I saw several answers that define their own commands to perform this or similar tasks, but I prefer a ...
2
votes
0answers
73 views

remove “” from lyx macro

I am using LyX and followed http://wiki.lyx.org/BibTeX/Biblatex. I don't want to use an absolute path with \addbibresource so I've tried following there example of using the \input@path macro. This ...
5
votes
3answers
135 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
871 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
86 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
21 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
51 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
407 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
87 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
87 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
52 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
39 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
41 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
187 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} ...