Quantcast
Channel: Insert text except whenever it will be placed at the end of a line - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 3

Insert text except whenever it will be placed at the end of a line

$
0
0

Is it possible have a command insert some text except in the casethat it will be placed at the end of a line? Here’s a simple (LuaLaTeX) example:

\documentclass{scrartcl}\usepackage{polyglossia}\disablehyphenation\newcommand{\sep}{\unskip\nolinebreak[4]~*~\linebreak[3]}\begin{document}\parbox{9cm}{%Arabel \sep Dusty \sep Octavia \sep Dinny \sep Demetris \sep Thomasa \sepCherie \sep Deeann \sep Page \sep Jesse \sep Kitti \sep Ruthie \sep Cory \sep Kathleen \sep Kaylyn \sep Chelsie \sep Floe \sep Verna \sep Torey \sep Cissy \sep Nora \sep Krissie \sep Hesther \sep Virgie \sep Liliane \sep Abagael \sep Joyann \sep Siobhan \sep Pierette%\parfillskip=0pt\par}\end{document}

enter image description here

The \nolinebreak[4]and \linebreak[3] commands are there to avoidhaving a line break before the separator character and to encourage a line break after it(especially useful if the names separated by\sep contain spaces).

I want to have the separator printed between all names,but not if it comes at the end of the line (there the line break acts as a separator). I have tried using a \discretionary, but that didn’t work, since the \linebreak command adds a linebreak after the discretionary, not inside it.

I use LuaLaTeX, so I’m open to a LuaTex solution. Here’s how I want the result to look (though perhaps with other line breaks).

enter image description here


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images