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

learn more… | top users | synonyms (1)

3
votes
2answers
40 views

xmakefirstuc combined with MakeTextLowercase

I am trying to convert a string as in the example, with all lowercase characters except the first. However, xmakefirstuc does not like me that much. Here's my MWE: % arara: pdflatex ...
8
votes
2answers
74 views

Creating bullet-list from string with delimiters

I want to create a bullet list from a string with delimiters in it. The delimiter in my example is | Example string: This is|A bullet|List from|A string I want to get that to become a bulletlist ...
8
votes
1answer
33 views

Defining a reusable string from within an environment

I write documents that rely heavily on the 'enumerate' environment. I'd like to turn any particular item from within that environment into a variable that I can use elsewhere. The idea is to ensure ...
0
votes
1answer
50 views

ifthenelse equal string comparison fails

I am trying to fix some problems with the accessibility.sty package from www.babs.gmxhome.de There is one string comparison which always results to false, i.e. the language code definition will not ...
0
votes
0answers
20 views

How do I use \StrSubstitute for a custom environment containing custom commands (Use of \@xs@StrSubstitute@@ doesn't match its definition)

This might be a tricky one... I have a custom command which highlights "properties" \pdesc{Property name}{DE}{EN}. Depending on the language (determined using the jobname), either the DE or EN ...
6
votes
1answer
176 views

How do I implement a string buffer in TeX?

I've recently learned how to create a macro to iterate over a token sequence using \afterassignment and \let in TeX. Currently, I'm trying to apply this to a tokenization macro (where "tokenization" ...
1
vote
1answer
34 views

Extra the word 'numberstyle' in listing

What's wrong with this ? I define listing style like below. \definecolor{codegreen}{rgb}{0,0.6,0} \definecolor{codegray}{rgb}{0.5,0.5,0.5} \definecolor{codepurple}{rgb}{0.58,0,0.82} ...
4
votes
2answers
44 views

Replacing substrings by linebreaks

I have a LaTeX document with several authors that I enter like \author{First Author \& Second Author \& .... In some places in the document I want to print these authors with a linebreak ...
3
votes
2answers
90 views

Listings problem with quotes in a string

A single quote occuring inside a listings string seems to be interpreted as ending the string. Is there a way to avoid this from happening? \documentclass[12pt]{article} \usepackage[top=0.3in, ...
3
votes
2answers
84 views

numberstringnum or numberstring in lowercase

I have tried a lot to use the \numberstringnum and \numberstring macros but it appears incomplete or even do not appear on the text. So I tested in the female version, like below: ...
4
votes
1answer
74 views

Extract from a token containing a list with math content

I have a token which contains a list consisting of: a date in YYYY-MM-DD format, followed by a colon, and some text which may contain math. The text will consist of a sentence or two (i.e., no ...
21
votes
2answers
625 views

Change the color of capital letters

Is there a way to define a command that changes the colour of any capital letter in an input string? Most of the results I find when I type "LaTeX string capital" are results about capitalizing the ...
3
votes
2answers
69 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, ...
3
votes
1answer
67 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} ...
8
votes
2answers
132 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>% ...
2
votes
1answer
96 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 ...
3
votes
1answer
87 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} ...
14
votes
2answers
360 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
43 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
27 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
105 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
899 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 ...
8
votes
1answer
121 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 purpose I tried to do the following (out-commented lines are meant to show what I'm aiming ...
6
votes
1answer
157 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
149 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
179 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
122 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
61 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
88 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
1k 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?
4
votes
1answer
463 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: ...
2
votes
1answer
116 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 ...
3
votes
2answers
81 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 ...
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
149 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
146 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
124 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, ...
7
votes
1answer
175 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 ...
4
votes
3answers
82 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
101 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): ...
1
vote
1answer
96 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
202 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 ...
3
votes
1answer
51 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
106 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
308 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
66 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
187 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
363 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
814 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} ...