Skip to main content

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
1 vote
1 answer
59 views

Can I use IfSubStr to search pgf key values that contain footnotes?

I would like to search some pgfkeys values for particular substrings. My attempt to locate such functionality in the manual didn't pan out, so I turned to using "\IfSubStr" from xstring. ...
user182238's user avatar
2 votes
2 answers
86 views

Re-center text after string substitution

What I want to do I want to display the date (year / month) on the cover of my document in Japanese. I have used the datetime2 package in other places in my document to print the date in English ...
Patrick's user avatar
  • 155
0 votes
1 answer
115 views

Locally delete ^ and _ in braces

I want to delete ^ and _ in a braces like \left( and \right) so that size change of braces ignores super and subscripts. I want to define it as a macro, but use of xstring package does not allow me to ...
Joseph's user avatar
  • 13
1 vote
1 answer
65 views

How does one fully expand a macro between \csname and \encsname?

The best way to ask this question is to present two MWEs, one of which works and one of which does not. Naturally, I would like to get this into the second form, but I am at a loss as to what is ...
Mike Pugh's user avatar
  • 329
2 votes
4 answers
166 views

How to modify overlay specifications in a new command in LaTeX Beamer?

I would like to modify the overlay specification that is passed to a custom command, but for some reason, < and > are interpreted as ¡ and ¿ when they are included in a new command. MWE: \...
mapf's user avatar
  • 253
2 votes
2 answers
138 views

Checking if a certain fragment is located earlier in the document

Very often I want to refer to a certain claim I mentioned earlier in the document: "As I said earlier, blah." Since I often rearrange material, I need to ensure that "blah" indeed ...
Jabot's user avatar
  • 149
1 vote
3 answers
160 views

I made a complex number command

So I've written a command as a homework assignment to render complex numbers correctly. Like, when I write \complfull{5}{-2} the output is 5-2i \documentclass{scrartcl} \usepackage{amsmath} \...
editilly's user avatar
2 votes
2 answers
66 views

Evaluation inside StrGobbleRight

I'm running into a problem with a list of IfSubStr that will be separated by commas and spaces. I don't want the final substring to have that comma and space, so I thought StrGobbleRight(2) would be ...
Rolling Seduction's user avatar
2 votes
3 answers
187 views

Find Text Between tabs [closed]

I copied a sheet from google sheet into a *.txt and want to format it to a pdf. I could separate it with \loop\unless\ifeof\mytextfile \read\mytextfile to\mytextline So I have in every loop one of ...
CHP's user avatar
  • 23
2 votes
2 answers
115 views

How to pass an argument to a macro called with \csname

I have a macro that generates lists of random numbers and converts them into letters to print. I'd like to create another macro that prints those lists with intervening text. That is, if \first ...
CBaker's user avatar
  • 23
1 vote
1 answer
85 views

getting automatically the initials of names

This sounds like some basic stuff, and yet I cannot manage to find a solution, packaged or native. I have documents with people who have from 2 to 4 names (typical Danish name could be Søren Jens ...
22decembre's user avatar
6 votes
1 answer
275 views

How to get the first three letters of today’s day of week?

I tried using the package datetime2 to get the whole name of today’s day of week and then xstring to trim it as desired. But when I run the following code, the result is not trimmed at all: \...
Myvh's user avatar
  • 63
0 votes
1 answer
63 views

Converting String Coordinates to Number Coordinates (e.g. ab -> 1 and 2)

I'm trying to draw stones on a grid, and my macro API will have two ways of doing it: either you give the X and Y coordinates, or you give it a string of the coordinates. So, for example, ab should be ...
psygo's user avatar
  • 438
5 votes
4 answers
322 views

An expandable command that adds a string to an argument if the string is missing

I would like to write and expandable command which adds a string S1 at the beginning of another string S2 if S2 does not start with S1 in order to ensure that my string always start by S1. I currently ...
Vincent's user avatar
  • 5,327
0 votes
0 answers
22 views

Elsarticle: obtaining appendix section label letter? [duplicate]

When using Elsevier's article template elsarticle, the references to appendix sections return Appendix X instead of X. I personally dislike the double space, so I was trying to create a macro to ...
FxMySz's user avatar
  • 3
3 votes
1 answer
130 views

Parse every character and transform it into a table column

I am trying to produce an array that will output most ascii characters in a given LaTex font. Currently, I have the following awful code that works: \documentclass{standalone} \usepackage[utf8]{...
Vincent's user avatar
  • 5,327
0 votes
1 answer
58 views

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

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
  • 153
0 votes
1 answer
85 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
30 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
  • 158
4 votes
2 answers
171 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
  • 683
0 votes
1 answer
50 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
39 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
69 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
36 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
52 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
52 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
549 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
66 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
629 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
76 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
  • 33
3 votes
1 answer
90 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
93 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,888
0 votes
1 answer
72 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
  • 77
0 votes
1 answer
36 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
  • 976
2 votes
1 answer
82 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
46 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,206
1 vote
1 answer
102 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,885
2 votes
2 answers
137 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
50 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
47 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
  • 5,327
0 votes
0 answers
121 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,747
0 votes
1 answer
38 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
148 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
184 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
73 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
64 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
86 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
42 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
32 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
2 3 4 5
8