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

learn more… | top users | synonyms (1)

3
votes
1answer
55 views

How to select all occurrences of a specified word in a string and append another word to each of them?

When using infix-RPN package, we can use \infixtoRPN to convert infix expression to RPN expression. The output of the conversion can be retrieved by invoking \RPN. \infixtoRPN{cos(x)+sin(x)}, for ...
1
vote
1answer
110 views

Making Back-Referencing More Pretty

The question Back-referencing in LaTeX was marked a duplicate, so I can't post to that thread. Nonetheless, I found the code provided there by Ryan Reich to be a good learning exercise. His solution ...
15
votes
3answers
321 views

Parsing strings containing diacritical marks (macros?)

I apologize that this question may seem very much like several other recent ones I have asked (Parsing leading hardspaces, Parsing a \$ as part of an improved \getargs command). They are all related ...
1
vote
0answers
71 views

Listings: Format part of a string differently (markup language inside a string) [closed]

I made a new language definition for a .NET template engine where part of the strings in the C# code are markup. Example: string templateString = @"{% for name in names %} Hallo {{ name }} {% ...
16
votes
3answers
2k views

\string command behavior - Plain TeX

I would like to learn Plain TeX and I'm reading Knuth's "The TeXBook". At Chapter 7, Knuth talks about the \string command and how it converts control sequences into lists of characters tokens. Why ...
7
votes
1answer
204 views

How to detect that some macro expands to empty string or spaces only?

I need to check several macros and do some actions only if their expansion is not empty nor space only. In pseudo code I would look like this \if\macroToBeTested \doSomething ...
8
votes
4answers
460 views

Tokenizing and parsing a word

After a 10+ year LaTeX hiatus I am returning and slowly getting hold again of macro writing. I now want to parse a string like "fisis" into the first letter "f" and the second half "isis". Case ...
7
votes
4answers
1k 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} ...
5
votes
1answer
98 views

String lowercase equality (newbie question)

i'd like to test if a string, once transformed into lowercase is equal to a given string. Here a MWE of what i'm talking about : \documentclass[a4paper,10pt]{report} \usepackage[francais]{babel} ...
4
votes
1answer
114 views

Translate string into TIPA

I am writing a project about phonetics using the tipa package. The problem is, I need to publish two separate versions of my project using different phonetic notation standards. When considering the ...
5
votes
2answers
487 views

Replace asterisk with nothing in string

I have a function which grabs cells out of a table and returns them. Many of these cells end with two asterisks, and I would not like these returned from the function if they are present. For ...
10
votes
1answer
295 views

How to replace a given string in a bibliography with biblatex?

Mendeley allows you to emphasise Latin names in article or report titles using HTML notation like so: A treatise on the ecology of <I>Rattus rattus</I> Using biblatex, the tags are ...
5
votes
1answer
73 views

Testing for commercial at (@) in a string [duplicate]

Possible Duplicate: Changing catcode for commercial at (@) inside a macro to get it matched in pattern. I want to test whether a string contains the @ sign. I came up with the following ...
3
votes
1answer
175 views

Get two short subtitles out of a too long title

Is there a way to get n shorter strings out of a long one in Latex? Let's say I have something like \title{A very long title} and I want it to be broken into two pieces such that I can later use ...
3
votes
2answers
191 views

canonicalize file path strings in TeX

I have a package which recursively loads many little modules (essentially tex files) from relative file paths. As modules may load other modules, I have to be careful not to load modules twice, so I ...
12
votes
3answers
2k views

How to concatenate strings into a single command?

I'd like to concatenate several parts of math text into a single command, and i read a great solution here on this site, allowing me to create this working example of what i mean : ...
7
votes
2answers
516 views

How to use @STRING variables in the note field of a .bib file?

I defined a @STRING in my .bib file as follows: @STRING{mytext = {Last accessed: }} This is an entry in the bibliography. @ARTICLE{knuth:1974, author = {Knuth, Donald E.}, title = {{C}omputer ...
2
votes
1answer
342 views

from string to command

What exactly happens in: \newcommand{\mystring}[1]{\gdef\@mystring{#1}} when \mystring{mystring} is used later in the document? It is known that mystring will be put in \mystring but I would like ...
4
votes
1answer
208 views

The command \string does not print curly braces of its argument

While printing the List of Symbols, I would like, in a draft, to print the definition commands as well. For instance, consider the following commands: \providecommand{\perm}{\ensuremath{\pi}} ...
6
votes
1answer
304 views

Why can't I compare a string with \par?

First of all: the package xstring cannot recognize a \par as argument. When I for example do this: \usepackage{xstring} \def\apar{\par} \def\str{a string} \IfStrEq{\str}{\par}{% true part }{% false ...
5
votes
2answers
513 views

Error using \string

Consider \documentclass{article} \usepackage{lmodern} \usepackage[T1]{fontenc} \begin{document} \texttt{\string\iftrue} %% \texttt =\long macro: %% #1->\ifmmode %% ...
12
votes
2answers
1k views

Alphabetic comparison of two strings

I tried to compare two strings (alphabetically), but I found some problems using the \pdfstrcmp command: 1- because it needs pdftex; 2- because it is case sensitive. The first problem is not so ...
3
votes
2answers
381 views

Number of \ (backslash) characters in a string

I'm trying to built a code that counts the number of \ in a string. My code can work with any other symbols (for example, if I need to count the number of 'a's, that works). I already tried to modify ...
4
votes
1answer
252 views

PGF loop variables in string comparisons

In a bigger context, I need to check whether an integer parameter is contained in a set of numbers. I decided to encode sets as strings; elements are separated by !. I don't know whether this is the ...
20
votes
4answers
2k views

How to convert a one digit number to a two digit number

I have a table that represents a timetable for bus, so each cell contains time of departure as hour followed by minute, both as two digits, but sometimes I don't have two digits,just one so I have to ...
7
votes
1answer
233 views

Comparing LaTeX3 token list to string

Is there a way to compare a LaTeX3 token list to string without having to create a temporary token list? I though I'd use \tl_use:N to get the contents of the token list for the comparison, but that ...
4
votes
1answer
239 views

How to compare two dates using TeX primitives

This is a follow up to TeX capacity exceeded while parsing a date string I want to compare two dates, say today's date and a due date. I have the due date information stored (as number strings) in ...
10
votes
3answers
472 views

TeX capacity exceeded while parsing a date string

I'm trying to parse a date (say, a due date) in a DD-MMM-YYYY format, e.g., 06-May-2012 and create macros \dueday, \duemonth, and \dueyear. I use xstring's commands to extract the substrings. Then I ...
2
votes
3answers
302 views

How to replace an expression in several TeX files?

Can I replace all instances of one string expressions in the TeX files in one directory? For example, let's say I want to replace all \frac with \myfrac in more than one file simultaneously.
1
vote
2answers
588 views

Arbitrary string assigned to variable?

How can I assign an arbitrary string - that may include special characters or even macronames - to a variable just as it is? e.g. like this: \newcommand{\mystring}{\assignstring{abc{}\w'\macroname ...
7
votes
1answer
577 views

Macro to extract (typeset) 'plain text' from a command?

Sorry to come back again with a similar post title (I had a post with this same title, then renamed it to PDF Metadata - Macro to extract (typeset) 'plain text' from a command?) - but I hope now the ...
2
votes
1answer
155 views

Xstring dealing with macros

I wrote the \bib command to reference authors in my thesis not using numeric or alpha references of natbib. It copies a piece of text, cut the first 60 characters (the width of my page} and put it ...
5
votes
2answers
372 views

String test, with complicated arguments

I have a command \mycom{} which takes 1 argument. The command should perform a test on the argument and do something accordingly. For simple arguments, I can use \ifthenelse, but I need to consider ...
20
votes
3answers
2k views

Extract first & last characters of macro argument?

In LaTeX, how do I extract/isolate/determine the first and last characters of a macro argument? Specifically, in the case I'm dealing with, the argument happens to be a base-10 integer (call it N). ...
9
votes
3answers
1k views

Extract number from string and compare problem

I try to extract the year, month and day from a string and write different text depending on the given date. I thought I could use xstring and etoolbox, but I can'st get it to work. Here's the code ...
3
votes
0answers
105 views

listings bug: space after quote collapsed when inlined with spaceflexible/fullflexible columns [duplicate]

Possible Duplicate: listings bug: space after literate replacement lost with spaceflexible/fullflexible columns I seem to have stumbled upon a minor bug in listings (version 1.4 as of ...
2
votes
2answers
241 views

String manipulation in ConTeXt

The ConTeXt wiki has an article about string manipulation, however, when I copy the code directly into my tex file, it compiles this code as text and does not try to compile it. There must be some ...
6
votes
1answer
337 views

BibTeX author tag string limitation

I've stumbled upon a limitation within BibTeX. I have to cite a medline entry which admittedly has a huge list of authors. When I take them all, LaTeX refuses to compile my document, when they're ...
5
votes
1answer
164 views

Substituting strings only when not bounded by letters or numbers

Using StrSubstitute from xstring I can find and replace matches. For e.g.: \StrSubstitute{I like to eat fish.}{fish}{apples} gives "I like to eat apples." \StrSubstitute{Do you want to ...
9
votes
2answers
1k views

Replacing characters in argument strings

I am trying to create a LaTeX command that will allow me to insert pre-defined tables with a minimum of fuss. This will also allow me to change the overall format of tables (e.g. caption above or ...
3
votes
2answers
183 views

Command representing an expansion of a summation

I am very new to using LaTeX to write equation. And I am now learning how to create my own command. I am going to write a command \Listn to help me to do this: \Listn{\sumup}{(#1)}{+} $\sumup{n}$\\ ...
6
votes
1answer
10k views

Using string variable with LaTeX

I would like to define one variable containing some text that can be changed locally. The following code gives one example of the featuring I'm looking for. \documentclass{article} ...
15
votes
3answers
14k 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 ...
3
votes
1answer
136 views

Splitting parameters in a macro

I have a macro like this: \newcommand{\listanimals}[1]{ Animals in the farm: #1. } So using \listanimals{pig / sheep / cow / duck / goat} will print: Animals in the farm: pig / sheep / cow ...
17
votes
4answers
554 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 ...
7
votes
2answers
552 views

Replace characters in string based on preceding and following character

The following two strings are the result of the expansion of a biblatex citation command: Unicom Computer Corp. (in re), 13 F.3d 321, 30 Collier Bankr. Cas. 2d 655, 25 Bankr. Ct. Dec. 152 (9th ...
8
votes
1answer
204 views

How to place a # character in a message?

How can I place a # symbol inside of a \PackageWarning inside of a macro definition? I tried: \PackageWarning{package}{# or \# or \string# or \hash} but either ## or unknown (for \hash) or Illegal ...
7
votes
1answer
526 views

string manipulation and catcodes

I want to detect whether an input line contains a certain substring, similar to the problem discussed here: Check if a string contains a given character The complicating problem is that the match ...
0
votes
1answer
2k views

“backspace” a character

It's not really "backspace" a character: I define a command, for example \foo representing bar, actually a macro for replacement. I need to produce the string bars with \foo. It's impossible to just ...
8
votes
2answers
360 views

Words of more than 32765 characters

When I compile the following document: \documentclass[10pt, oneside, a4paper]{report} \begin{document} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \end{document} where the number of x's is greater than ...