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

learn more… | top users | synonyms (1)

5
votes
2answers
473 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
985 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
251 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 ...
3
votes
1answer
215 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
1k 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 ...
6
votes
1answer
201 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 ...
3
votes
1answer
206 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
411 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
249 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
396 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
451 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
151 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
346 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 ...
17
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). ...
8
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 ...
2
votes
0answers
103 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
229 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 ...
5
votes
1answer
233 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
145 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 ...
7
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
168 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
6k 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} ...
13
votes
3answers
10k 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
131 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 ...
13
votes
3answers
420 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 ...
6
votes
2answers
518 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
191 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
485 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
351 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 ...
3
votes
2answers
445 views

Split long string into paragraphs

How can I test a string to see if it has more than one paragraph, and split a string that contains multiple paragraphs into two strings, one with the first paragraph of the original, one with the ...
3
votes
1answer
711 views

Letting strings start with a capital letter

I am writing a small book and try to build up an index reference. To make it a little easier I wrote a small script that enables my to type a word and also add it to the index: ...
6
votes
3answers
462 views

Conditionally including a TikZ figure

I have the following construction for a figure. The background is, when \submit is defined, only the caption is included, but no figure. Otherwise the figure is included. The problem is that I have ...
6
votes
3answers
262 views

How to remove all dashes (-) using a macro?

In a package, I'm building macro names from the values of options passed to a function. Now, the values should also allow a - inside, but the command names I'm building with \csname do not. So, I need ...
6
votes
2answers
1k views

How to concatenate strings, to e.g. create commands that return lists?

I was thinking about Felix' Question, where he wanted to return lists in TikZ. My approach so far was to return the single results as individual \nodes, separated one centimeter each. Now I would like ...
3
votes
4answers
621 views

Generating dummy text programatically using TeX/LaTeX

As part of an attempt to debug another problem, I have a need for a TeX/LaTeX command that generates some dummy text in place. I know of lipsum and blindtext, but they are not what they want. What I ...
5
votes
3answers
448 views

Programmatically setting a counter to a substring

I'm trying to set a counter based on the name of the current job. I've got the number I need by doing something like \substring{\jobname}{5}{5}} using the stringstrings package, and if I just output ...
1
vote
1answer
609 views

Using \footnotesize in tikz node labels

I have used \footnotesize to scale labels before and it has produced the desired results. But am having problems when I pass this as part of the label to a macro. The following MWE compiles but not if ...
2
votes
2answers
270 views

Include LaTeX file named with substring of current filename

I'm frequently creating presentations with beamer and need both the handout and the presentation itself. To avoid editing the file when I need to compile the other, I use \ifdefined\ishandout ... at ...
1
vote
2answers
283 views

\pgfmathdectobase macro \pgfmathresult digit index or bitwise operators

Is there a way to access each digit of a macro returned by \pgfmathdectobase (or \pgfmathresult) which is a binary number ? This would be useful for a function which prints the power set of a given ...
6
votes
1answer
315 views

\StrLeft has no effect on \citetitle

\footfullcite uses too much space so I decided to define a own command. I called it \footshortcite. It only display a pre- and a post-Option and the Author with Year. However, I don't like that most ...
3
votes
1answer
164 views

Force stringification of a length

I'm trying to include a background image of the correct size based on the two variables \IApaperheight and \IApaperwidth. To do this, I'm converting the lengths to a rounded text value and ...
5
votes
2answers
172 views

Changing catcode for commercial at (@) inside a macro to get it matched in pattern.

This question is related to TikZ: pgfutil-common: pgfutil@in@ - how does it work? and is a result of coping with that problem. I've already read How to change #catcode in a macro, but it didn't help ...
5
votes
1answer
367 views

TikZ: pgfutil-common: pgfutil@in@ - how does it work?

Having been writing small lib for TikZ, I tried to use this macro in order to search for @. Code compiled, but the result was false, despite that I was sure it was in tested string. So, I decided to ...
2
votes
1answer
1k views

How to pass a \def parameter to an inner command (StrSubstitute)?

I'm attempting to create 2 macros to simulate an array list as in Java for example. I'm using xstring StrSubstitute for this purpose, but I'm having a problem. Below is the code, it's a bit long as it ...
6
votes
1answer
627 views

How to capture the result of \StrSubstitute into a macro?

I have a macro, say defined as follows: \edef \temp{A.input 1} I want to replace the dot with hyphen and have the result being stored in \mystart. Something like that: \edef ...
4
votes
2answers
792 views

Nest StrLen and ifthenelse commands

Here is a sample of code I am working on: \documentclass[10pt]{report} \usepackage{xstring} \usepackage{ifthen} \begin{document} \StrLen{123456}\\ %Prints 6 ...
2
votes
4answers
280 views

Replacing entries in a csv list

I want to replace entries in a csv list, where the list parser can be arbitrary (eg: ,;:|). An example follows: \def\x{r;s;t;x;y;z} In this list I want to efficiently replace r,t,x by a,b,c via, ...
8
votes
1answer
277 views

How do I store the upper case counterpart of a string?

I have a string stored in a variable \word, and I want to store its upper case counterpart in another variable \WORD. If I try \def\WORD{\MakeUppercase{\word}} \show\WORD then the message ...
21
votes
2answers
3k views

How do I split a string?

I need to split a string into one or more substrings. I know that I could use the xstring package, but I'd like to do it using only inbuilt TeX/LaTeX commands. So, if I say \def\MyTeXKnowledge{Not ...