I would like to know if it is possible to program a function that would accept a given symbol an infinite number of times. The application I have in mind is the following. I would like, if possible, a command \spac which would take two booleans and by default be defined as \vspace*{0.5ex}.
It would take two symbols.
The
*says if there is a line break or not; thus, \spac* is defined as\\[0.5ex].The presence of one
+means that there will be a0.5ex \vspace increment.The specificity here, is that we should be able to add as many
+as we want, or, if not possible (this is part of the question, to determine whether it is possible or not), a reasonably high number of them such as 5 or 6.
To sum up, each + will add 0.5ex to the total vertical space. The vertical space will thus always be equal to 0.5*(n+1)ex, n symbolizing the number of +s.
I would like the +(s) to be written directly without separators, just like a t+ argument type.
Examples:
\spac+++++will produce a vspace of0.5*6 = 3ex, without a line break.\spac*++will produce a line break and a vspace of0.5*3 = 1.5ex.
Context
\documentclass{article}
\usepackage{linguex}
\usepackage{etoolbox}
\NewDocumentCommand{\tslt}{m}{`#1'}
\makeatletter
\patchcmd{\a}{\ifnum\theExDepth=2\topsep .3\Extopsep\else\topsep 0pt\fi
\parsep\z@\itemsep\z@}
{\ifnum\theExDepth>1\topsep\csname pxtop\roman{ExDepth}\endcsname
\itemsep\csname pxitem\roman{ExDepth}\endcsname\else\topsep\z@\itemsep\z@\fi
\parsep\z@}{}{}
\makeatother
\newlength{\pxtopii}
\newlength{\pxtopiii}
\newlength{\pxitemii}
\newlength{\pxitemiii}
\newcommand{\spaceab}[1]{\setlength{\pxitemii}{#1}}
\newcommand{\spaceii}[1]{\setlength{\pxitemiii}{#1}}
\newcommand{\spacebefa}[1]{\setlength{\pxtopii}{#1}}
\newcommand{\spacebefi}[1]{\setlength{\pxtopiii}{#1}}
\newcommand{\alignright}{\hspace{1em}\raggedright\hspace*{\fill}}
\NewDocumentCommand{\web}{o}{%
\begingroup\alignright%
(\textsc{web}\IfValueT{#1}{,~#1})\endgroup\par}
\begin{document}
\spaceab{1ex}
\spacebefa{2ex}
\ex. Example 1\label{ex1}
\a. Sublevel1a\label{ex1a}\
\tslt{translation 1a}
\b. Sublevel1b\label{ex1b}\
\tslt{translation 1b}
\spaceab{2ex}
\spaceii{1ex}
\ex. Example 2\label{ex2}\
\a. sublevel2a
\a. sublevel 2ai\
\tslt{translation 2ai}
\b. sublevel 2aii
\tslt{translation 2aii}
\z.
\b. \a. sublevel 2bi\
\tslt{translation 2bi}
\b. sublevel 2bii\
\tslt{translation 2biii}
\b. sublevel 2biii
\tslt{translation 2biii}
\z.
\b. sublevel2c\
\tslt{translation 2c}
\ex. Example XXXXX
\tslt{translation}\web\vspace*{1ex}
\end{document}
Depending on how heavy the sentences and translations are, and how the overall look feels, I adjust the spacings. The space before a translation is given with some \vspace*{} value. But the line break sometimes is already given by the previous command (such as \web), so i do not want to systematically integrate it.



\\or add vertical space without glue. – cfr Mar 03 '24 at 06:07linguexwill visualise what you mean and be able to answer without one, but I think it would still be good to see what you're doing now. I suspect this is an XY problem, which makes it hard to help without some context. – cfr Mar 03 '24 at 06:25\web\vspace*{1ex}not\web\\vspace*{1ex}but perhaps you mean\web\\ \vspace*{1ex}hard to tell when that fragment isn't runnable. – David Carlisle Mar 03 '24 at 09:49\\has to be in hmode otherwise it generates an error as it's a line break within a paragraph\parends a paragraph if it's in one and does (almost) nothing if it is not. – David Carlisle Mar 03 '24 at 10:05\raggedrightin that definition isn't doing anything (as you end the group before it is used) but again you only provide this in an untested fragment not in your test file. – David Carlisle Mar 03 '24 at 10:07