Questions tagged [strings]

{strings} are sequences of characters (most commonly literal constants). However TeX doesn't have the same concept of strings as other languages, so for questions regarding text in general this tag does not apply. Usually when dealing with {strings} one also uses the primitive {pdfstrcmp} or dedicated packages, such as {xstring} or {expl3}'s string module (l3str).

Filter by
Sorted by
Tagged with
3
votes
1answer
23 views

Convert string of rational number to a variable and back [duplicate]

How can I convert LaTeX variables and strings when dealing with rational numbers? I have found many working examples for integers, but none for rational numbers. \documentclass[12pt]{article} \begin{...
2
votes
1answer
49 views

Get \string-ification of first opening brace in argument?/Get \string-ification of first opening brace's matching closing brace in argument?

Can you write a LaTeX macro where the output is the result of applying \string to the argument's first character token with category code 1 which is not a control-sequence-token and not an active ...
5
votes
1answer
77 views

Cases of different tokens having same meaning and same \string-representation that can occur in the stage of expansion

Please take this question for a moot point: I'd like to know about edge cases where different tokens which TeX might encounter during expansion without delivering error-messages have the same meaning ...
1
vote
0answers
48 views

String equality check [closed]

I want to compare 2 strings and perform different tasks based on their results(using if-else loop) My code is here: \tab• \hyperlink{new}{New Features, Enhancements, and Changes}\linebreak \begin{...
5
votes
2answers
339 views

Is there a way to use string manipulations to make macro names?

Bottom line up front: what is a convenient way to input a particular character string into a \newcommand call so it can be manipulated to create multiple macro names? In particular, input (say) ABC ...
0
votes
1answer
73 views

Finding minimum and maximum values of arguments in function

I am defining a \newcommand called \eventsperiodslist which call some other commands: \event[]{Digits}{} and \period[]{Digits}{Digits}{} The arguments called "Digits" in \event and \period ...
10
votes
5answers
449 views

Test if an argument starts with a particular string

Is there a way in tex to test if an argument starts with some string or not? And then extract the text that follows that start? As an example, I want to define a command that makes a text bold if it ...
1
vote
1answer
40 views

Build a command for article contracté in European languages

I would like to build a command \contraction{<prep>}{<art>} to do the "article contracté" in European languages. For example, I would like to have \contraction{de}{le} return du ...
0
votes
1answer
43 views

Splitting comma separed by comma

I'm using two indexes to build a bilingual glossary. Some words have two or more equivalent in the target language, so I should separate those equivalent in the target index. For example: the word -...
3
votes
1answer
33 views

Detection if image path contains string fails

For a project I would like to check if my included image is located in the sub-folder graphs or not. To check that I wrote a small MWE: \documentclass[% reprint, amsfonts, floatfix, amsmath,amssymb, ...
1
vote
1answer
42 views

TeX \ifx conditional not working for string comparison

I would like a LaTeX source file to compile in different ways depending on the job name. However, when I run pdflatex mwe with mwe.tex containing \documentclass{article} \begin{document} \ifx{mwe}\...
13
votes
3answers
344 views

xstring - How to define a macro that removes final punctuation?

Is it possible to create a command to remove final punctuation from a sentence (here to simplify, just remove the final period)? Thanks to the xstring package, I can remove the final punctuation for a ...
3
votes
1answer
58 views

How to extract the fontname from \the\font

I know LaTeX doesn't have strings as such but I want to be able to get and save the human readable version of the current font name. \f@family does not work as expected because it shows the base font ...
6
votes
3answers
256 views

Split string into part by char position

Explanations I format a moroccan RIB (Relevé d’identité bancaire for “Bank account number”) to display it as a nice rendering. I need to take each part of the RIB to embrace it with a specific label. ...
2
votes
2answers
81 views

Find if a string exists within external files

I'm trying to look for a way to determine if a particular text or string is present in external .tex files. It is like accepting a text input from a user and determining if that text can be found in ...
7
votes
3answers
925 views

Base64 encoding in LaTeX?

How can we encode some text/string using Base64 encoding in LaTeX? or any alternative solution? For example, the Base64 encoding of string Latex is bGF0ZXg=. Here's a representation of what I want to ...
1
vote
3answers
81 views

LaTeX3 - Test string equality + Star version

I'm looking for some good advice on switching from (La)TeX to LaTeX3 Here is the first questions corresponding to the toy code below. What is a good way to manage an optional argument with LaTeX3? ...
0
votes
1answer
35 views

File name comparison with underscore

We have tested \filename{XYZ-2100011} and \include{XYZ-2100011} both input tex file name matched or not, otherwise we passed error messages in the macros. In my cases how to support input file name ...
1
vote
1answer
25 views

File name string comparison

Need to show compilation error if "\filename{XYZ-2100011}" and "\include{XYZ-2100011}" input filename mismatch. For example, if \filename{ABC-2100012} and \include{XYZ-2100011} ...
1
vote
1answer
49 views

How can I get a single character from a string?

I'm trying to make a command (macro? not sure about terminology) that takes in as input a string s, a number n, and a character c, and returns true if the nth character of s is c, and false otherwise (...
0
votes
2answers
52 views

How to multiple underline characters in strings

I need to show examples of border, cover and other regularities on a string and I would like to show that by underlining the characters of a string accordingly. Also I would like to have a larger font ...
3
votes
1answer
66 views

How to use a string argument to create a macro name and invoke the resulting macro name?

I get part of a macro name as an argument. I want to use that to form a complete macro name and invoke it. How can I do that? Here is a test case to demonstrate what I am trying to achieve: \...
0
votes
2answers
119 views

"\includegraphics{}" but for .pgf files?

I'm trying to implement a command that makes it easier to put .pgf files in my document (plots from matplotlib), similar to how \includegraphics[scale=...]{...} works for image files. However, because ...
2
votes
2answers
83 views

Conditional with multiple conditions, one of which is a string search

Aim I want a command to write "where #1 is an arbitrary constant", "where #1 are arbitrary constants", "where #1 is an arbitrary function of #2", or "where #1 are ...
2
votes
1answer
131 views

How to use macro with Journal Abbreviations?

I have downloaded these macros from this page. How to use it? I copy the macros to my file macros.tex. Also, I tried to save to a separate file and use \include{}. In both cases, I obtained an error ...
0
votes
0answers
156 views

BibTeX -- runaway string warnings?

I get these runaway string warnings which don't seem to stop my LaTeX from compiling but are annoying. How the heck am I supposed to locate a "possible" runaway string which starts at line ...
1
vote
0answers
38 views

Getting the name of control sequence token - which values of \escapechar besides 32 require special attention?

I'd like to get the name of a control sequence token as sequence of character tokens. With \relax I'd like to get relax. The preceeding escape character is to be removed from the result of \string\...
0
votes
2answers
55 views

How do I compare a specific string to strings from a group using a loop?

I want to compare members of a group of strings to an specific string. Why is this not working ? \documentclass{beamer} \usepackage{tikz} \begin{document} \foreach \n in {x,Enu}{ \begin{frame} \...
7
votes
4answers
919 views

Simple implementation of the abs function by getting rid of or by consuming the "-"?

I wish to build a (simple) implementation of abs. I tried \FPabs but I get a lot of zeros after the decimal point. I could get rid of them with the FP round function, but I don't know the number of ...
1
vote
1answer
41 views

Write CSV in document with dynamic filename

I'm super new to Latex and I'm trying to do automatic documents that present information regarding each project. Every folder and project has a different name/code and I'd like the document to add a ...
5
votes
2answers
84 views

How to get string length from multi-byte character string when passed as a \def using pdftex

I need to determine the number of printed characters from a multi-byte string. Further, the strings are passed to the routine via \def (ultimately via the readarray process to input a csv file). I am ...
3
votes
2answers
258 views

\pdfstringdef turns accented characters into octal escape sequence

The Question : How to make a glowing text? @'Symbol 1', interesting, I encapsulated your script into a new command (named '\glow') so I could highlight text just like with '\hl{}'. However the result ...
2
votes
1answer
96 views

Test for substring with expl3 in argument of \setlength

I want to test if a string contains a substring. I finded good answers in this question. But I encounter a problem with the first answer of egreg using expl3 and I don't get the same problem with ...
1
vote
1answer
103 views

Help to make a faster token replacing macro

I have a macro called \logic which helps me write logical formulas faster by simplifying some common logical symbols. So when I write $\logic{p -> q}$ I obtain $p \to q$. Here's the code: \...
1
vote
0answers
88 views

LuaTeX - printing string literal producing strange dots

When I try to print a literal string with LuaTeX, these strange dots appear. Does anyone know why? Any suggestions to work around this? I was thinking of parsing the literal string line by line and ...
1
vote
1answer
82 views

how to auto newline in path string in latex

I am write path in latex like this: /data/docker/nginx/volume/conf/conf/conf.d/cert/example.com but the string is too long for compile to pdf, compiled result like this: how to handle the path ...
0
votes
2answers
64 views

String comparison on \citefield result

I'm using \citeall with a custom entry formatter to list all the entries in my bib file, but I'd like to conditionally format entries from a specific journal. To do this, I've tried using \ifthenelse ...
1
vote
1answer
39 views

expl3 - Counting the number of leading spaces of an argument

How can I count the number of leading spaces and not all spaces as with the use of \str_count_spaces ? Concretly I would like to read a content line by line and for each line of input I would use the ...
3
votes
3answers
150 views

searching for strings

Is there a TeX macro (in plain or AmS-TeX) that wil search for a specific string of characters? Specifically, I want a macro which will be part of an if/then macro of the form, if a given string xyz ...
2
votes
3answers
65 views

How to convert the last number of the ref command output to string

There is an answer explaining how to convert numbers to text here. But if I use a \ref output in the command \convertdigits, it throws the error Missing number, treated as zero. even if the ref output ...
2
votes
2answers
76 views

Split regarding | and then merge

In the following MN(ot)WE, how can I fix \merge so that it merges the preceding values made automatically by \split? The last code gives 1 | 12 | 123 | 1234 instead of 1 > 12 > 123 > 1234. \...
2
votes
0answers
111 views

Lua function that replaces strings, but ignores spaces and TeX comments

I would like a Lua function for LuaTeX, called replaceButIgnoreSpacesAndComments (<string>, <what to replace>, <what to replace it by>) It is supposed to work like a string ...
2
votes
2answers
44 views

Why does \substring not work inside \equal?

Why does this code output "False": \documentclass{article} \usepackage{stringstrings} \usepackage{xifthen} \begin{document} \ifthenelse{\equal{\substring{ab}{1}{1}}{a}}{True}{False} \end{...
0
votes
1answer
89 views

Why is the output of \pageref{label} not a string?

I made a small macro to create crossreferences from one footnote to another. The page number of the referenced footnote should not be printed if both footnotes appear on the same page. That should be ...
0
votes
1answer
27 views

pgfplotstable: String replace in a table with meta-data from another table (using a foreachloop)

I have a main-table Data.txt with some contents col1, col2, col3 a, b, c x, y, z aaa, abc, xyz where I want to replace some strings. If I say \pgfplotsinvokeforeach{x,y,z}{ \pgfplotstableset{string ...
1
vote
3answers
66 views

How do I store the current value of a macro as an permanent string?

Long story short, I have been using \patchcommand within a \whiledo loop to try to construct a string piece-meal from an old string, inserting certain characters along the way. I cut off a bit of the ...
1
vote
0answers
36 views

pdfLatex output has "Copyright (c) AMS". How to remove?

Compiling with pdflatex: \documentclass[11pt]{article} \begin{document} 1 \end{document} and postprocessing with gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -sOutputFile=b.pdf a.pdf and running ...
0
votes
0answers
83 views

Ignoring doxygen comments in listings

I have a C project that I am documenting in latex. It features doxygen comments (like those /** bla */ /**< blab */ /// bla blub ///< blubber). I use the listings package to include parts of the ...
1
vote
1answer
3k views

How to return latex as string from Python back to Latex document using pythontex package

I know how to use basic pythontex with single variables. But now I am trying to do something more than basic. I'll explain what the problem is, then given MWE below. To run the MWE requires having ...
1
vote
1answer
69 views

For loop within itemize + arrays of strings

Consider a document in which there are a few sections containing lists. The content is predictable; the list is preceded by a tiny preamble. Something like this: \documentclass{article}% % BASIC ...

1
2 3 4 5
9