8

In my CV, I have lists that look like this:

wizardry \tdot fluid dynamics \tdot applied bear wrangling \tdot calculus \tdot [...]

where \tdot is a \textperiodcentered character along with some hspace. This type of separation is entirely insensitive to the line wrapping, so if space runs out in a line, then according to chance

  • an item might be divided, even hyphenated,

  • or there might be \tdot's standing at the end of one or beginning of the next line

These two together don't leave any ambiguity, you always know where one item ends and the other begins. However, they are also somewhat ugly. Here's an image:

typeset example with problem zones highlighted

Is there a way that I can make them both disappear? That would imply

  • Defining groups of words that do not break

  • Having a dividing thing that knows not to appear just before or just after an automatic line break

Edit: Here is a MWE of how it was done originally.

\documentclass{report}
\makeatletter
\makeatother

\newcommand{\entrylabel}[1]{\mbox{#1}\hfil}

\newenvironment{CV}
  {\begin{list}{}
{\renewcommand{\makelabel}{\entrylabel}
\setlength{\labelwidth}{77pt}
\setlength{\leftmargin}{84pt}
  }}
  {\end{list}
}

\newcommand{\tdot}{\hspace{0.4em}\textperiodcentered\hspace{0.6em}}

\begin{document}

\pagestyle{empty}

\begin{CV}
\item[Experimental] mechanics \tdot fluid dynamics \tdot thermodynamics \tdot waves \tdot electromagnetism \tdot optics \tdot atomic physics \tdot nuclear physics \tdot particle physics \tdot astrophysics \tdot astroparticle physics, methods and detectors \tdot cosmology \tdot neutrino astronomy \tdot accelerator physics and technology \tdot statistics and data analysis
\end{CV}

\end{document}

2 Answers 2

8

The following example puts the items in macro \titem instead of using a separator macro \tdot. This way it is easier to put the entry into a \mbox to prevent a line break inside the item.

The separator dot is lost at line breaks, if it is set as "leaders". Usually this is used for repeated stuff like dotted lines in the table of contents. But it is also possible to specify just one repetition. Since TeX treats this construct as horizontal glue, it vanishes at the begin of a new line:

\documentclass{article}
\usepackage[hmargin=20mm]{geometry}

\makeatletter
\newcommand*{\titem}[1]{%
  \mbox{#1}%
  \@ifnextchar\titem{%
    \hspace{0pt plus 1em}%
    \sbox0{\,\textperiodcentered\,}%
    \cleaders\copy0\hskip\wd0 %
    \hspace{0pt plus 1em}%
  }{}%
}
\makeatother

\begin{document}
  \noindent
  Experimental\qquad
  \begin{minipage}[t]{110mm}
    \titem{mechanics}
    \titem{fluid dynamics}
    \titem{thermodynamics}
    \titem{waves}
    \titem{electromagnetism}
    \titem{optics}
    \titem{atom physics}
    \titem{nuclear physics}
    \titem{particle physics}
    \titem{astrophysics}
    \titem{astroparticle physics}
    \titem{methods and detectors}
    \titem{cosmology}
    \titem{neutrino astronomy}
    \titem{accelerator physics and technology}
    \titem{statistics and data analysis}
  \end{minipage}
\end{document}

Result

Of course the line breaking is now much harder for TeX. The spacing around the dot can be quite small or very huge depending on the lengths of the items.

A variant with \raggedright:

\documentclass{article}
\usepackage[hmargin=20mm]{geometry}

\makeatletter
\newcommand*{\titem}[1]{%
  \mbox{#1}%
  \@ifnextchar\titem{%
    \sbox0{\space\textperiodcentered\space}%
    \cleaders\copy0\hskip\wd0 %
  }{}%
}
\makeatother

\begin{document}
  \noindent
  Experimental\qquad
  \begin{minipage}[t]{110mm}
    \raggedright
    \titem{mechanics}
    \titem{fluid dynamics}
    \titem{thermodynamics}
    \titem{waves}
    \titem{electromagnetism}
    \titem{optics}
    \titem{atom physics}
    \titem{nuclear physics}
    \titem{particle physics}
    \titem{astrophysics}
    \titem{astroparticle physics}
    \titem{methods and detectors}
    \titem{cosmology}
    \titem{neutrino astronomy}
    \titem{accelerator physics and technology}
    \titem{statistics and data analysis}
  \end{minipage}
\end{document}

Result

Applied to the MWE of the updated question:

\documentclass{report}

\newcommand{\entrylabel}[1]{\mbox{#1}\hfil}

\newenvironment{CV}
  {\begin{list}{}
{\renewcommand{\makelabel}{\entrylabel}
\setlength{\labelwidth}{77pt}
\setlength{\leftmargin}{84pt}
  }}
  {\end{list}
}

\makeatletter
\newcommand*{\titem}[1]{%
  \mbox{#1}%
  \@ifnextchar\titem{%
    \hspace{0.4em plus 1fil}%
    \sbox0{\textperiodcentered}%
    \cleaders\copy0\hskip\wd0 %
    \hspace{0.6em plus 1fil}%
  }{}%
}
\makeatother

\begin{document}

\pagestyle{empty}

\begin{CV}
\item[Experimental]
\titem{mechanics}
\titem{fluid dynamics}
\titem{thermodynamics}
\titem{waves}
\titem{electromagnetism}
\titem{optics}
\titem{atomic physics}
\titem{nuclear physics}
\titem{particle physics}
\titem{astrophysics}
\titem{astroparticle physics, methods and detectors}
\titem{cosmology}
\titem{neutrino astronomy}
\titem{accelerator physics and technology}
\titem{statistics and data analysis}
\end{CV}

\end{document}

Result

5
  • Wow, thanks for conjuring up that solution and taking such care to present it! Any chance I can make that whole thing with \item[Experimental] words * with * dots instead of the noindent and minipage?
    – user207046
    Commented Jun 10, 2014 at 18:08
  • What I mean is, right now, when I try just inserting your titem's it gives me "TeX capacity exceeded, sorry [input stack size=5000]".
    – user207046
    Commented Jun 10, 2014 at 18:14
  • @ChrisRa: Since I do not know, what you are doing, make a minimal working example (MWE). Commented Jun 10, 2014 at 18:21
  • Of course - sorry, I'm new. I've put an MWE at the end of the question!
    – user207046
    Commented Jun 10, 2014 at 18:35
  • I don't understand how, but the latest one totally works. Brilliant, you've helped a lot!
    – user207046
    Commented Jun 11, 2014 at 22:17
2

Here's an alternative approach:

\documentclass{article}
\usepackage{xstring}

\newcommand{\entrylabel}[1]{\mbox{#1}\hfil}

\newenvironment{CV}
  {\begin{list}{}
{\renewcommand{\makelabel}{\entrylabel}
\setlength{\labelwidth}{77pt}
\setlength{\leftmargin}{84pt}
  }}
  {\end{list}
}

\newlength{\DLwidth}

\newcommand{\DLbase}[1]% #1 = comma delimited keywords
{\StrCut{#1}{,}\DLleft\DLright%
\loop% extract keywords from list
\StrCut{\DLright}{,}\DLnext\DLright%
\settowidth{\DLwidth}{\DLleft\DLdot\DLnext}%
\ifdim\DLwidth<\linewidth\edef\DLleft{\DLleft\DLdot\DLnext}%
\else\DLleft\DLline%
\edef\DLleft{\DLnext}%
\fi%
\if\DLright\relax\else\repeat%
\DLleft}

\makeatletter
\def\DotList{\@ifstar\DLragged\DLflush}
\makeatother

\def\DLflush#1{% flush right version
\def\DLdot{\hfil$\cdot$\hfil}%
\def\DLline{\linebreak[4]}%
\DLbase{#1}}

\newcommand{\DLragged}[1]% ragged right version
{\def\DLdot{ $\cdot$ }%
\def\DLline{\newline}%
\DLbase{#1}}

\begin{document}
\begin{CV}
  \item[Flushright]{\DotList{mechanics,fluid dynamics,thermodynamics,waves,electromagnetism,%
  optics,atom physics,nuclear physics,particle physics,astrophysics,%
  astroparticle physics,methods and detectors,cosmology,neutrino astronomy,%
  accelerator physics and technology,statistics and data analysis}}

  \item[Raggedright]{\DotList*{mechanics,fluid dynamics,thermodynamics,waves,electromagnetism,%
  optics,atom physics,nuclear physics,particle physics,astrophysics,%
  astroparticle physics,methods and detectors,cosmology,neutrino astronomy,%
  accelerator physics and technology,statistics and data analysis}}
\end{CV}
\end{document}

dot list

7
  • Looks good, but with your code I just get Undefined control sequence ...d technology,statistics and data analysis}
    – user207046
    Commented Jun 10, 2014 at 19:13
  • Oops, I left off the pt on 0pt. Commented Jun 10, 2014 at 19:19
  • That got rid of a further error that I didn't post, but the other one is still there. Sorry, I don't think I can figure this out either.
    – user207046
    Commented Jun 10, 2014 at 19:22
  • I get no errors, and I copied the code back from here to make sure. Commented Jun 10, 2014 at 19:32
  • I revised the solution to combine flush right and ragged right versions. Commented Jun 11, 2014 at 19:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .