Quantcast
Channel: Active questions tagged starred-version - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 63

In(de)finite number of Boolean arguments

$
0
0

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 a 0.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 of 0.5*6 = 3ex, without a line break.
  • \spac*++ will produce a line break and a vspace of 0.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.


Viewing all articles
Browse latest Browse all 63

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>