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).
526 questions
4
votes
2
answers
145
views
expl3 strings: control sequences introduce erroneous space
Context (not to be confused with ConTeXt)
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\sys_shell_now:n {C:\cygwin64\bin\mintty.exe}
\ExplSyntaxOff
\end{document}
returns
'C:\cygwin' is ...
6
votes
3
answers
303
views
Create string expansion in a single command
I am uncertain of what terms to search for to ask this question, but my goal is something along these lines:
\documentclass{article}
[\mycommand definition]
\begin{document}
1: \mycommand{a,b}
...
3
votes
2
answers
185
views
Splitting math expressions to macros
I want to split the general math interval expression into four tokens(?) so I can then handle different cases. In other words, I need a command that receives (a,b) as an argument and define four ...
2
votes
1
answer
57
views
Override inner command to only be used if it is called with specific macro arguments
I have an \outercmd, which uses an \innercmd multiple times with various macros calls e.g.
\newcommand{\outercmd}{
\innercmd{\fooOne{}}
\innercmd{\fooTwo{}}
\innercmd{\fooThree{}}
}
I'd like to be ...
4
votes
2
answers
115
views
How to detect changes in an environment between latex runs?
I'm writing a package that provides an environment, say DoSomethingIfChanged. The environment writes it's content to file and then does [something] with it (run LaTeX on it, but I think this does not ...
0
votes
0
answers
24
views
strip trailing character (rstrip implementation) [duplicate]
I am trying to implement an rstrip-like functionality that removes a specified trailing character (once is enough), I found this answer https://tex.stackexchange.com/a/315805, however their expl3 ...
3
votes
2
answers
168
views
StrChar on consecutive spaces
I'd like to get characters at specific indices from my argument. I'm trying to use \StrChar, but it seems that it collapses consecutive spaces:
\documentclass{paper}
\usepackage{xstring}
\begin{...
5
votes
1
answer
168
views
In LaTeX3 how to trim spaces only left or right?
In LaTeX3, the command \tl_trim_spaces:n allow to trim spaces at both ends of an input. How to do exactly the same, but:
Only the spaces that are prefixing the input (left)
Only the spaces that are ...
0
votes
5
answers
162
views
Add $k$ instances of a certain character [duplicate]
I'm trying to write a latex command that will allow me to concatenate k times a certain string. Both k and the string will be provided as input. However, I'm having trouble starting. I want to make ...
4
votes
1
answer
122
views
Separate/split a string into number groups and no-number groups
The following code could recognize a single number. but how to revise it such that it can split abc23.46de789f into {23.46 789} and {abc de f} ?
\documentclass{article}
\begin{document}
\def\xloop#...
6
votes
1
answer
174
views
Why filenames defined through expl3 strings don't work with \setmainfont?
With the following MCE, we see that filenames can be defined through either (expl3) token lists (..._tl) or strings (..._str) for \input: both work. By contrast, for \fontspec's \setmainfont, only ...
2
votes
1
answer
133
views
What is the role of \tl_to_str:n versus using directly the functions from the l3str module?
Let's say I am creating an expl3 macro:
\cs_new:Nn \my_function:n{
% Something
}
I have hard time understanding the exact role of \tl_to_str when processing the argument compared to "just&...
9
votes
5
answers
1k
views
How to exit loop when encounter first integer in string
This is some code.
\documentclass{article}
\usepackage{xstring}
\begin{document}
\def\xloop#1{%
\ifx\relax#1
\else
**\IFInteger{#1}{first integer is here.}** % need to be modified
...
7
votes
1
answer
337
views
How do I examine an integer in a text
I found some code on from this link How to split text into characters
But \IfInteger function not work
\documentclass{article}
\usepackage{coolstr}
\usepackage{xstring}
\begin{document}
\...
1
vote
1
answer
64
views
How to use \isnumeric function provided by the "coolstr" package?
I meet a problem when use \isnumeric function in coolstring package. After compilation with pdflatex engine, nothing is output in pdf file. Below is the code.
\documentclass{article}
\usepackage{...