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).
505
questions
1
vote
1
answer
25
views
Conditionally omit protocol from hyperlink texts based on URL (Cambridge University Press style)
The Cambridge University Press style guide mandates the following formatting for URLs:
’http://’ and ‘https://’ should not be included before ‘www.’. However, if a URL does not include ‘www.’ then ...
2
votes
1
answer
38
views
Link produced by href taking a command as first argument is not working "as I want"
I am trying to define a command that takes a bib key, gets its title, author, and DOI, and makes a hyperlink in which the link is the DOI address and the text shown is the paper title. I need this to ...
1
vote
1
answer
102
views
Test whether a string is in a list
\documentclass{article}
\usepackage{expl3,xparse}
\usepackage{currfile}
\ExplSyntaxOn
\NewDocumentCommand \IfStringInList {mmmm}
{ \clist_if_in:nnTF {#2} {#1} {#3} {#4} }
\ExplSyntaxOff
\begin{...
2
votes
2
answers
48
views
Convert list to table, number of rows
A small program that recalculates the number of records in the source list (array) and converts the list of data into a table.
It works if the number of rows in the table is \def\nRows{3} is ...
2
votes
1
answer
97
views
Comparing strings using LaTeX3
Yesterday I asked a question about the "currfile" package I wanted to use for writing a document about several pupils in my school and @cabuha provided a very nice answer for this problem: ...
4
votes
1
answer
84
views
Problems when extracting chars from data imported from csv file
In a previous post
I want to compare the last character of a string with other characters
I asked how to compare the last character of a string with another char, and the solutions offered have solved ...
2
votes
2
answers
215
views
I want to compare the last character of a string with other characters
I want to compare the last character of a string with other characters.
If I type
\ifthenelse{\equal{f}{f}}{OK}{NOT OK}
it returns OK. HOWEVER, if I type
\substr{asdf}{-1}{1}
it returns f, BUT
\...
2
votes
0
answers
87
views
Latex text reversing with Babel package
I am using the babel package, which causes text-reversal when combined with amsmath.
The exact list of packages I use is:
\usepackage[utf8x]{inputenc}
\usepackage[hebrew,english]{babel} % Workaround ...
1
vote
1
answer
56
views
Print \twocolumn and \onecolumn [duplicate]
How can I print \twocolumn and \onecolumn because \\ makes a new line.
\documentclass[a4paper,12pt]{article}
\ExplSyntaxOn
\NewDocumentCommand {\lumnar} {}
{
\\twocolumn~and~\\onecolumn~always~...
3
votes
2
answers
74
views
how to transfer from a text variable a small piece of text
with the following code, I set a variable \AcIII with the bla bla text.
I would extract a part of variable (i.e. the first two bla bla) and store it on another variable (that I use next).
Can I obtain ...
0
votes
3
answers
60
views
In Latex3, how to test if all tokens in the input verify a test (for example \token_if_letter or \token_if_space)?
In Latex3, I would like to write a function that checks if every token of an input verify a predicate.
Basically I would like the multitoken version of this command:
\NewDocumentCommand{\mychecksingle}...
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 ...
4
votes
3
answers
183
views
How to substitute placeholders in string with arguments?
I'm writing a document in two languages using the macro \enzh defined as below:
\documentclass{article}
\newif\ifen
\entrue % comment out to switch to Chinese
\newcommand{\enzh}[2]{\ifen#1\else#2\fi}
...
1
vote
2
answers
42
views
Splitting string and retrieving part of it
I would like to take a string in Beamer and retrieve part of it. The solution at How do I split a string? gets me very close to what I want; but using it as example, i.e. if the string is:
\def\...
2
votes
1
answer
81
views
Why it appears that seqsplit fails to break some strings?
I know it is possible to break long lines using the seqsplit package. The following code block shows a minimal working example.
\documentclass{article}
\usepackage[a4paper, showframe]{geometry}
\...