Questions tagged [xstring]

provides macros manipulating strings of tokens. For a basic use, tokens can be alphanumeric chars, but the macros can also be useful for manipulating tokens

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 views

How do I replace a specific string with its bold version?

I want to bold my own name in the publication section of my CV. I have tried: \usepackage{xstring} \newcommand{\highlightname}[1]{ \StrSubstitute{#1}{My Name}{\textbf{My Name}} } \begin{enumerate} ...
HappyFace's user avatar
  • 143
0 votes
1 answer
78 views

Unwanted offset when using biblatex's printbibliography and author bolding via xstring+etoolbox

I'm trying to bold my name in a publication list. After an embarrassing amount of time/experimentation I have something I'm happy with via etoolbox and xstring: \renewcommand{\mkbibnamegiven}[1]{\...
daknowles's user avatar
  • 103
0 votes
1 answer
23 views

How to \immediate\write multiple lines produced using \newline and \StrSubstitute

Why this does not work when the lines are produced using \newline (instead of ^^J) and \StrSubstitute as follows? Thanks \documentclass{article} \usepackage{xstring} \begin{document} \def\mystrings{\...
Krantz's user avatar
  • 159
4 votes
2 answers
161 views

How can I parse a # from a macro argument?

I want to write a macro such that \ghpr{myrepo#1234} expands to \href{https://github.com/my-username/myrepo/pull/1234}{myrepo#1234}. (I know how to do it for \ghpr{myrepo}{1234}, but I'd prefer to ...
Eric's user avatar
  • 539
0 votes
1 answer
43 views

Finding an int among a list of int

I'm trying to find a command or define a command that takes a list of integer and an integer and does things when the integer in in the list and does something else if it is not the case. I have seen ...
Rhylx's user avatar
  • 3
0 votes
0 answers
33 views

How do I search for a substring and highlight the occurrences?

How do I create a command which, given a string (let's assume just a single word) and a substring (let's assume just a single letter of the alphabet), outputs the given string with all the occurrences ...
stf's user avatar
  • 243
2 votes
1 answer
54 views

\StrSubstitute doesn't work on the string produced by the \ref macro

In this LaTeX code I attempt to replace the "(" in references, so that they would look like "x)", not "(x)": \documentclass{article} \usepackage{enumitem} \usepackage{...
Flying Jay's user avatar
2 votes
0 answers
31 views

xstring testing: help needed for testing chords typeset with leadsheets package

For a personal songbook project I use the leadsheets package. Later on, I want to automatically typeset guitar chord diagrams based on the chords of a song, even if the song is transposed via the ...
KSTNR's user avatar
  • 53
0 votes
0 answers
41 views

Why does using IfEndWith inside DeclareNameWrapperFormat throw an error?

I wanted to use this solution for having possessive citations in BibLaTeX, but extend it to account correctly for names ending in 's' (at least in english). The solution posted in that question does ...
modallyFragile's user avatar
0 votes
0 answers
34 views

Test within new command - xstring package

I am trying to create a new command, to test wether another command ends with the string "...s\xspace" or "...\xspace", where the dots are other characters than s. I've found that ...
Squared2's user avatar
4 votes
5 answers
468 views

Comma separated list replacement

I have a comma-separated list of information provided by the author as a preamble to my document. I then want to use this list and I'd like to put one item from my list per line. My idea was simply to ...
Clem's user avatar
  • 45
1 vote
1 answer
58 views

\IfDecimal returning Number to big

\IfDecimal returns an error number to big with large decimal. My goal is to print a percent rounded to to places if it is a number, otherwise just print the value of the parameter. Is there away ...
Mombird's user avatar
  • 13
6 votes
6 answers
602 views

Delete string up to last slash

\documentclass{article} \usepackage{xstring} \begin{document} \StrBehind[2]{/foo/bar}{/} \StrCount{/foo/bar}{/} \StrBehind[\StrCount{/foo/bar}{/}]{/foo/bar}{/} \end{document} I'm trying to delete /...
Michel Charpentier's user avatar
1 vote
1 answer
65 views

Macro to conditionally generate tikz-cd diagrams

I'm trying to define a macro that will generate a tikz-cd diagram with small changes in it based on the arguments I pass to the macro call. I'm using xstring package to express conditions. My first ...
Ivan's user avatar
  • 13
3 votes
1 answer
88 views

Why does \IfStrEqCase print the url of \href?

Motivation I'm writing a biblatex bbx file for philosophers, and I want to include eprint support (like that which is builtin for arXiv) for the Stanford Encyclopedia of Philosophy. The SEP requests ...
modallyFragile's user avatar
2 votes
2 answers
84 views

xstring font change

Simple question. I have two macros for displaying abbreviated days of the week such as MWF or TR. I am not sure why the first macro in my MWE fails while the second macro works. I would prefer that ...
User23456234's user avatar
  • 1,611
0 votes
1 answer
53 views

Get date from filename and format it

I was trying to customize the header of a document when I encountered some difficulties. I'm working on this project in which there are several .tex files and each one is named as yyyyMMdd.tex. My ...
Lorenzo's user avatar
  • 67
0 votes
1 answer
35 views

Automatically customizing the front cover of different memoirs

I need to create several memoirs with the same format. For each document I want to customize several features of the front cover, for example the background color. I'm trying to automate the ...
Tonechas's user avatar
  • 974
2 votes
1 answer
52 views

Getting a substring from a string which is stored inside a variable in LaTeX

I currently have the following problem for which I couldn't find a solution for. It's about getting a substring from a string variable... I've a nested list of values: \ExplSyntaxOn \...
Mahakala108's user avatar
1 vote
1 answer
45 views

Problem when extracting string from argument to call another function

In my program below, I defined a function \checklist that takes to optional arguments and one compulsory argument. The function works as expected. Then, I would like to define another function \...
anderstood's user avatar
  • 2,176
1 vote
1 answer
57 views

Formatting lines of \VerbatimInput

I have some text files I need to include in a document, preferably using fancyvrb or fvextra. I want to highlight some of the lines of these files. The exact conditions are not important here, since ...
vwegert's user avatar
  • 2,855
2 votes
2 answers
117 views

String conditional tikz

I am trying to make a print command for a board game (Amazons). I specify the dimensions and board state, so \AmazonsBoard{3}{3}{WXX---BXX} will draw a small 3x3 board. There are 4 different square ...
daan's user avatar
  • 23
0 votes
1 answer
33 views

Command to delete substring in "note" field of bibtex *.bst

I have a CV where all my presentations are formatted using "@misc" -- for some of the publications I would like to note them as "invited," and I have a version of my CV where I ...
weatherczar's user avatar
0 votes
0 answers
32 views

Parse and get specific results from string? [duplicate]

I have the following strings: lec-01.tex, lec-02.tex, ..., lec-10.tex, lec-11.tex, ... How can I parse these strings and get only the digits? Like, for the string lec-01.tex, how can I get only 1 and ...
SingularisArt's user avatar
1 vote
2 answers
43 views

Using string to process a macro name using listofitems seems to fail

I am trying to process the name of a command using listofitems, but when I am using \string to convert that command it does not behave the way I think it would behave. Here is a code to illustrate: \...
Vincent's user avatar
  • 4,703
0 votes
0 answers
94 views

How to conditionally define a new style in tcolorbox

I define a new tcolorbox option(key) named background color. If the valve given to it is a decimal, the backgound of the tcolorbox will have an effect of transparent -- eg. background color=0, else ...
lyl's user avatar
  • 2,677
0 votes
1 answer
33 views

Storing argument in a string for further use with \tabbing

I have a macro that stores some strings in \step0, \step1, \step2... I use the character "a" as a placeholder to be replaced down the line with \ = or \ > down the line (for use in the \...
FunkiePhil's user avatar
1 vote
2 answers
141 views

Conditionally remove trailing period

I have an abbreviation "f.o.o.". However, I might later want to change it to simply "foo". I thus define a macro in order to easily switch (by (un)commenting the relevant lines) ...
dwolfeu's user avatar
  • 473
5 votes
2 answers
174 views

First character of \ref{<label>}

Practically, I would like to decide if a reference to a label begins 1 or not. The question has some relevance in Hungarian. The idea was to use xstring package: \documentclass{article} \usepackage{...
MGy's user avatar
  • 115
0 votes
1 answer
64 views

Strange characters added when using 'xstring' functions in 'foreach'

I'm trying to create a macro which display a list of string and if a string start with '*', it apply specific style (like bold). So I'm using a foreach and xstring macros but something goes wrong with ...
Froz Armony's user avatar
2 votes
1 answer
46 views

How can I make expandable cite list?

I try to make a cite list, which usable with xstring. Here is an MWE: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{xstring} \makeatletter \NewDocumentCommand{\citelist}{m} {% \@...
hair-splitter's user avatar
0 votes
2 answers
69 views

Difficulty when using \ifthenelse{\equal{ }} to determine tilde (~) status

I'm having to determine whether the tilde (~) character exists at the end of a string, but I am seeing differing results depending on the macro, e.g: \documentclass{article} \usepackage{ifthen} \...
RosesBouquet's user avatar
1 vote
1 answer
37 views

How to check for the presence of a tilde (~) at the end of a text string?

How do I get to 'true'? \documentclass{minimal} \usepackage{xstring} \begin{document} \IfEndWith{string~}{\textasciitilde}{true}{false} \IfEndWith{string~}{\textasciitilde{}}{true}{false} \...
RosesBouquet's user avatar
0 votes
1 answer
24 views

Error when passing a command to a command when using IfSubStr

I am trying to build a command "TEST" which uses IfSubStr from the xstring package. When using the command, I need to pass another command "ARGUMENT" which contains a figure* ...
chris's user avatar
  • 3
1 vote
1 answer
102 views

Using a CSV File to Drive Custom Macro

Background I am trying to figure out why the attached MWE is not working. My custom macro reqUser works correctly when using the xstring both inside and outside of the csvsimple environment. The expl3 ...
Nebabon's user avatar
  • 115
6 votes
4 answers
807 views

What about "exotic" characters in xstring?

When I use the macro \StrLen on a string that contains one or more "exotic" characters, the value returned does not correspond to the actual number of characters in the string. I suspect ...
Jean-Louis Brabant's user avatar
2 votes
2 answers
64 views

Using \usepackage{tikz,xparse,xstring,fp} to create a lattice a lattice multiplication

\documentclass[tikz,border95=3mm]{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[case/.style={minimum width=2cm,minimum height=2cm,draw},line/.style={blue!10!gray,line width=...
Paul A's user avatar
  • 709
0 votes
0 answers
50 views

Using \vec inside \StrSubstitute to simplify math notation

I'm using several different calculi (programming languages) in a work, and I'm trying to define a tool to simplify my notation for them by replacing text with the proper notation; as of now, I've been ...
paulotorrens's user avatar
0 votes
1 answer
258 views

LaTeX3 Verbatim-Like Command Illegal in Argument

LaTeX cmd: Verbatim-like command '\checkboxYesNo' illegal in argument. I get the above message when I tried to migrate away from using tabu & xstring combination to tabularray & native LaTeX3 ...
Nebabon's user avatar
  • 115
1 vote
2 answers
100 views

write to file full expansion of command

I have an issue I want to resolve, maybe you can help me. When I compile the mwe the following happens: In the PDF you can see: (X/A)(Up/Down) In the file.txt write: (\frac {a}{x})(\frac {u}{d}) How ...
Alexander Rodríguez's user avatar
1 vote
1 answer
58 views

Use of \xs_IfStringCase_i doesn't match its definition?

I thought I had created a pretty straightforward command but apparently it's not allowed. I suspect I'd need to add \expandafter somewhere, but I'm not sure (where). I'd like to understand why in ...
Steven's user avatar
  • 153
3 votes
1 answer
292 views

how to get value from a list by the index

I build a list by a macro to store some values. I wonder if there is method to get value by its index number from the list. The following code shows my intention. Code example: \documentclass{article} ...
lyl's user avatar
  • 2,677
1 vote
1 answer
121 views

LaTeX3 Text/String Comparison Replacement for xstring

Trying to update my college's LaTeX thesis class (for fun while I wait for the actual degree to show up). It hasn't been touched in a few years. Anyways, one of the commands it has is below: % TODO: ...
Nebabon's user avatar
  • 115
2 votes
2 answers
50 views

How to return a filename containing underscore from a switch-case function (like ifEqualCase) as a parameter into a function like addplot?

When plotting and iterating through a list of filenames, I wanted to call them from a switch-code and apply them in \addplot. I used the switch-function \IfEqCase from the xstring package. However, ...
Jarl Øystein Samseth's user avatar
0 votes
1 answer
77 views

Automatically add section label based on file name

I am trying to automatically add section label based on the file name. My structure is as such: main.tex 1.0.introduction.tex 1.1.0.foo.tex 1.1.1.bar.tex I am using \currfilename from package ...
eliasf's user avatar
  • 141
0 votes
1 answer
116 views

How to extract year from date in iso 8601 format?

I want to extract the year (or day or month) of a date which is stored as ISO 8601 in a database. My MWE looks like: \documentclass{article} \usepackage{xstring} \usepackage{datatool} \newcommand{\...
lukascbossert's user avatar
0 votes
0 answers
133 views

How get the result of a macro that uses xstring functions before writing to a file

I encountered the need to write last name with initials (extracted from the full author's string based on first chars of first and middle name) into an external file. I use the xstring package to ...
Crosfield's user avatar
  • 119
8 votes
3 answers
1k views

String to lowercase and replace spaces with underscore

I am trying to convert a predefined string in a variable to its lowercase and replace the spaces to underscore. But it's not working. The new string after conversion is like this: ...
t.abraham's user avatar
0 votes
0 answers
89 views

Detokenize input to \newcommand

I would like to define a command that removes .m when referencing to the caption generate_simdata.m (i have a lot of such matlab function files, and would like to reference them normally with \nameref ...
justsome631's user avatar
0 votes
0 answers
38 views

Creating Modifiable Text

I was wondering if there was a way to create a string variable? I need to use a WHILE loop where I remove the first char of a string, and I need to have that saved. I tried other ways: to put the ...
Royolh's user avatar
  • 1

1
2 3 4 5
8