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

learn more… | top users | synonyms (1)

3
votes
2answers
48 views

Generate comma separated list with some non-empty strings

I'm trying to generate a comma separated list that uses strings that may or may not be empty. For example \mylist{\stringA,\stringB,\stringC} would expand to A, C if B is empty or B, C if A is empty, ...
8
votes
2answers
86 views

Split a character string n by n

I want to split a character string n by n. I know how to do that 1 by 1 : \documentclass{article} \makeatletter \def\s@plit<#1#2>{% \ifx\empty#2% #1% \else #1,\s@plit<#2>% ...
3
votes
1answer
41 views

convert string to active character

in my book I will have to itemize a lot of things in different lists. That's why I want to reduce my commands to a minimum. This script is just part of a bigger macro. \documentclass{book} ...
2
votes
1answer
54 views

Writing macros for tikz-cd arrow options

I'm trying to write a macro to let me write shorthand for tikz-cd arrows. For instance instead of having to write out the full command \arrow[swap, dotted]{r}{f^*} I'd like to have a shorthand ...
2
votes
1answer
43 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} ...
11
votes
2answers
243 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} ...
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
0answers
26 views

Comparing last character(s) of the output of \ref to manipulate output [duplicate]

I am trying to write a command that will replace \ref in a special way. It will add some text next to the number based on the last character(s) of the number \ref outputs. I will try to explain this ...
2
votes
1answer
60 views

Latex: splitting/processing strings inside a latex command

Let's say I have \ingredients {% \unit[375]{g} & Farina 00\\ \unit[250]{g} & Burro\\ \unit[3]{g} & Sale\\ 1 & Limone } (you got me: I'm dealing with xcookybooky) ...
14
votes
3answers
888 views

Equivalent to “in” operator

I want to write a command that responds to an argument being in one set of reference strings or another. The argument takes a (musical) note name, and the command will print an accidental depending ...
5
votes
1answer
74 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): ...
6
votes
1answer
141 views

Can I define a variable that contains a URL (youtube) and call \includemedia with it?

I can successfully embed a video in my latex file using a syntax like this: \documentclass[10pt,letterpaper]{book} \usepackage[latin1]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} ...
3
votes
2answers
115 views

Converting an underscored string to camelcase

I would like to take a string containing underscores and convert it to CamelCase. I am attempting to do this using the stringstrings package. Here is my code: \documentclass[11pt]{report} ...
10
votes
3answers
142 views

how to select a character (or word) from a list

Is there a way, with the following restrictions: No external pacakges (i.e., no substr) no conditionals (\ifnum, \ifdefined, etc) to select a character from a string? i.e. \CharAt{2}{ABC} ...
2
votes
1answer
109 views

Macro to get character width in ConTeXt

Background Looking to adjust the location of the first letter in a word based on its width. Problem The calculation resembles: \define[1]\StyleChapterChar{% \cldcontext{string.sub("#1",1,1)}% } ...
4
votes
1answer
57 views

Relatively placed overlay based on string length

Background Using ConTeXt I'm trying to reproduce the following result: The problem centres around the first character of the chapter title being offset a relative distance from the chapter title. ...
1
vote
1answer
79 views

Substrings in ConTeXt

Problem Trying to get the first letter of a word for a chapter heading. The chapter style is being applied as follows: \setuphead[chapter][ command=\StyleChapter, % Hide the header's ...
5
votes
4answers
752 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?
2
votes
1answer
106 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 ...
4
votes
1answer
284 views

pgfplotstable manage strings and values

I like the pgfplotstable package for reading and plotting tables but handling of strings and values (especially when strings contain spaces) drives me crazy... I often use a table as shown here: ...
3
votes
2answers
68 views

Replace and add a/to a specific sequence of tokens

Is there a way to find a specific sequence of tokens and add after it a command? Or is there a way to find a specific sequence of tokens and replace it with another one? And do it only if the sequence ...
7
votes
1answer
167 views

Change the way XeTeX sees a string before running/building PDF

For some reason, I'm really struggling to articulate my question, so let me apologise in advance. I may not be approaching this from the right angle. I'm working in XeTeX (and it's far too late to ...
6
votes
2answers
229 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 ...
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 ...
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 ...
4
votes
1answer
125 views

Errors in passing a previously concatenated string to foreach

Motivation While attempting to answer Pie chart with values as angles not percent, I stucked on passing a string to a foreach. The context To makes things clear, I briefly introduce the context. ...
3
votes
2answers
112 views

How to store and append text for later use (inside enumerate environment)

I'd like to make a container in LaTeX in which I can store and append LaTeX-code for later use. I have found many solutions to what I'm basically try to do (here for instance), but if they work, ...
4
votes
3answers
80 views

Automatically construct image file name

I have a lot of images numbered like so: image_0001.png image_0002.png image_0003.png ... I would like to set up a Latex command to include a specific numbered image, for example: ...
2
votes
2answers
89 views

use string variable as format string in \begin{tabu}

I have the following problem. I'm using the tabu package to create tables but instead of a format string like this: \begin{tabu}{ccc} I want to use a format string like this (as string variable): ...
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 ...
3
votes
1answer
175 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 ...
1
vote
1answer
84 views

How to expand keyval options immediately

I am trying to build up a macro that creates other macros depending on kvoptions' options. But then, the outcoming macros are dependent on the actual state of the options instead of their state at the ...
3
votes
1answer
50 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
102 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
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 ...
3
votes
1answer
150 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 ...
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
0answers
62 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 }} {% ...
15
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
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
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 ...
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
4answers
658 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
85 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
107 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
366 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 ...
9
votes
1answer
228 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
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 ...
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 ...
3
votes
2answers
165 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 ...