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

learn more… | top users | synonyms (1)

4
votes
1answer
133 views

Biblatex abbrevation for no author/editor/year/etc. in alphabetic style

I use an alphabetic citestyle with biblatex. Sometimes I have entries where no author or editor or year is given. For example there is often no editor for a proceeding. At the moment I leave the entry ...
0
votes
0answers
23 views

Strip control characters from token

I've added a hook to lstlisting to do some special highlighting. Now I've got it to highlight %-prefixed variables just fine, but I'd like to handle the special case "%this" in another way. ...
1
vote
0answers
17 views

Bibliography string 'print' undefined [duplicate]

I use biblatex and a special fonencoding for the cyrillic alphabet. Everything works fine, only the bibliography prints an additional, unwanted string 'print' at the end of each item. Here's my code: ...
9
votes
2answers
142 views

Replace every backslash in a string with a forwardslash

I would like to replace every backslash \ inside a macro (string) with a forwardslash /. The macro is intended to contain a filename in Windows notation which should be replaced by a valid (La)TeX ...
3
votes
1answer
45 views

Expand arguments in string substitution macro

Rewritten as minimum non-working example: \documentclass{article} \makeatletter \usepackage{xstring} \usepackage{xparse} \newcommand\textfromcase[1]{% \IfEqCase{#1}{% for the purposes of this ...
1
vote
1answer
48 views

A command for making a string of characters [duplicate]

How can I make a command (or is there an existing one?) which takes two arguments: 1) character type 2) N (count) and puts N number of characters side by side? \newcommand{\foo}[2] { % sample: ...
1
vote
0answers
20 views

Bibliography string 'by' undefined in Canadian

I use babel with the canadian language, and biblatex-chicago. If I use a @inbook reference with a bookauthor field, I get the following error: Bibliography string 'by' undefined at entry 'smith' on ...
32
votes
6answers
2k 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
5answers
400 views

A command which concatenates a string an arbitrary number of times

I'm trying to define a command \repeatstring{#1}{#2} which repeats the string #2 #1 times. Here is what I tried: (it is based on what I found in How to concatenate strings into a single command?) ...
4
votes
2answers
57 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
106 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 ...
17
votes
4answers
553 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 ...
8
votes
1answer
60 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
228 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 ...
14
votes
2answers
576 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} ...
6
votes
1answer
188 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" ...
3
votes
2answers
99 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: ...
1
vote
1answer
50 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
67 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 ...
8
votes
1answer
178 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 ...
3
votes
2answers
155 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, ...
4
votes
1answer
93 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
706 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
101 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
160 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
75 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
127 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
113 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} ...
5
votes
1answer
46 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
147 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
913 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 ...
6
votes
1answer
166 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
186 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
220 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
131 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
67 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
94 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
2k 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
134 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
682 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
86 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
182 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 ...
7
votes
2answers
514 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 ...
8
votes
2answers
185 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
173 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
129 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
89 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
124 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): ...
22
votes
2answers
4k 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 ...