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

learn more… | top users | synonyms (1)

26
votes
2answers
1k views

Introspection and reflection with LaTeX/TeX macros

Below is a short program that can use \meaning and \string to let a combination of LaTeX and TeX commands to print out the listing of macros. Unsurprisingly (nothing can surprise me with TeX any ...
15
votes
3answers
288 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 ...
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 ...
10
votes
3answers
413 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 ...
12
votes
7answers
967 views

How to get the string with \

Apologized for my unclear description. I wish I could explain my problem more clearly. In document, I wish I can just write something as "how to use \cmd \mbox in xxx" or "what is \cmd minipage ...
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 ...
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 ...
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 ...
11
votes
2answers
244 views

String comparison in \ifthenelse

I want find a certain line of text in a data file cities.txt: A;London B;Berlin C;Paris with the xstring and [xifthen][2] packages: \documentclass[12pt, a4paper]{article} \usepackage{xstring} ...
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 ...
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 ...
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
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 ...
5
votes
1answer
369 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
45 views

Using strings to list parameters for tikz-cd arrows

I'm trying to write some macros for making tikz-cd commutative diagrams. In tikz-cd you can give your arrows options like "bend left" or "dotted", in a comma-delimited list: \documentclass{article} ...
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 ...
29
votes
5answers
1k views

Censoring Curse Words with Grawlixes

Suppose that I would like to censor a curse word <word> using grawlixes, e.g. "What the #@$! are you doing?!" How can I define a command \censor such that \censor{<word>} results in a ...
14
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 ...
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 ...
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 ...
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 ...
8
votes
2answers
121 views

How can I combine two text strings to represent the name of a command?

I want to combine one command with a text string to represent a second command. In MatLab it would be possible to concatenate these two strings into one string and evaluate this new string. However I ...
7
votes
1answer
175 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 ...
6
votes
2answers
230 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 ...
13
votes
3answers
422 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 ...
9
votes
1answer
230 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 ...
8
votes
4answers
309 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 ...
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 ...
5
votes
1answer
37 views

Using \newcommand to format numbers/strings according to a pattern [duplicate]

I'm an aspiring LaTeX user and have so far managed the first steps and created my first few documents. Coming from a programming background I've been wondering how you could use \newcommand to create ...
5
votes
1answer
75 views

how to do multiple string replacements?

i want to escape URL paths to obtain the percent-escaping that is also applied e.g. by browsers; for this i tried to do the following (outcommented lines are meant to show what i'm aiming at here): ...
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 ...
4
votes
1answer
194 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}} ...
3
votes
4answers
622 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 ...
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 ...
2
votes
1answer
107 views

How to create a pre-processing command that accepts plain text and generates formatted text (based on configurable options)

Looking for the best way of creating a string-processing command in latex to achieve things like below: Given a long piece of normal text, and a set of keywords, automatically format the matching ...
2
votes
2answers
231 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 ...