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

learn more… | top users | synonyms (1)

5
votes
1answer
66 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
160 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
177 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 ...
11
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 : ...
6
votes
2answers
303 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
284 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
200 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
281 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
495 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
310 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
235 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 ...
7
votes
1answer
216 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
219 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
437 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
267 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
476 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
517 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
152 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
355 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 ...
18
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
104 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
237 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
277 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
156 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 ...
8
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
172 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
8k 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
12k 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
132 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
445 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
532 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
198 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
504 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
354 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
452 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
749 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
474 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
264 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
2k 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
713 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
490 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
673 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
281 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
288 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
323 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
170 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 ...