3

I use XeLaTeX with the memoir class to typeset my linguistics thesis. In the running text, I often mention prefixes, which have a following hyphen. For example: "un- is an inherited Germanic negation prefix".

Now, sometimes this prefix will be before a comma, or at the end of a sentence. And sometimes, LaTeX will insert a linebreak after the hyphen, but before the period. Here's a MWE:

\documentclass[a4paper,
openright,
oneside,
12pt,
]{memoir}
\usepackage{fontspec}
\usepackage{geometry}
\setmainfont{Linux Libertine}

\begin{document}
\noindent In (6.269), the first person pronoun \textit{wɨ} co-occurs with the coreferential bound marker \textit{j-}.
For Wayana, Tavares (2005: 413) states that first and second person pronouns cannot occur in P position.
\end{document}

Here's what it looks like:

enter image description here

Now, I don't understand why LaTeX would allow a period at the start of the beginning. The OP of How to avoid a linebreak before a comma? was also wondering that, but no satisfying solution was found there. I have also seen Line break after command, before period, which features a non-basic custom command.

Any ideas?

6
  • A simple solution would be to use an en dash – instead of a hyphen -. I actually prefer that for citation forms of morphemes.
    – Alan Munn
    Commented Oct 19, 2020 at 14:14
  • 1
    While this might be a solution for some individual cases, it is not a general solution. In my specific MWE, it does not work -- the only difference is the length of the line, but the linebreak is the same!
    – folran
    Commented Oct 19, 2020 at 14:32
  • It certainly works for me with your MWE as posted.
    – Alan Munn
    Commented Oct 19, 2020 at 14:35
  • For me, this code does not work, and I think I've used a standard en-dash? ` \documentclass[a4paper, openright, oneside, 12pt, ]{memoir} \usepackage{fontspec} \usepackage{geometry} \setmainfont{Linux Libertine} \begin{document} \noindent In (6.269), the first person pronoun \textit{wɨ} co-occurs with the coreferential bound marker \textit{j–}. For Wayana, Tavares (2005: 413) states that first and second person pronouns cannot occur in P position. \end{document} `
    – folran
    Commented Oct 19, 2020 at 14:48
  • You mean you still get the linebreak after the en dash?
    – Alan Munn
    Commented Oct 19, 2020 at 14:52

3 Answers 3

2

The problem arises because TeX thinks a that a hyphen is always a good place to break a line. It doesn't really know about the beginning of the line, in the sense that it can avoid putting a . there. So a word that ends with hyphen will always potentially pose this problem.

You can use the solution adopted by the ngerman language definition file to create a non-breaking hyphen as discussed in the first question you link to How to avoid a linebreak before a comma?. Here I've just made a \nbhyphen command to introduce a no-break hyphen. Alternatively, you could define a \prefix macro which would add the hyphen automatically. I've replaced your \textit with \emph since you want the formatting of words/morphemes to revert automatically to upright if they are themselves embedded in \emph.

\documentclass[a4paper,
openright,
oneside,
12pt,
]{memoir}
\usepackage{fontspec}
\usepackage[english]{babel} % for textormath macro
\usepackage{geometry}
\setmainfont{Linux Libertine O}
\providecommand{\texorpdfstring}[2]{#1}
\newcommand\nbhyphen
{%
  \texorpdfstring{\textormath{\leavevmode\hbox{-}}{-}}% tex string
                 {-}% PDF string
}
\newcommand\prefix[1]{#1\nbhyphen}

\begin{document}


% use \nbhyphen
\noindent In (6.269), the first person pronoun \emph{wɨ} co-occurs with the coreferential bound marker \emph{j\nbhyphen}.
For Wayana, Tavares (2005: 413) states that first and second person pronouns cannot occur in P position.

% alternate syntax: make a command for prefix
\noindent In (6.269), the first person pronoun \emph{wɨ} co-occurs with the coreferential bound marker \emph{\prefix{j}}.
For Wayana, Tavares (2005: 413) states that first and second person pronouns cannot occur in P position.

\end{document}

output of code

1

If luatex with babel is an option, you can use the tools provided by the latter to deal with special hyphenation cases. In this particular case, the following should work:

\usepackage[english]{babel}

\babelposthyphenation{english}{={.}} % (1)
 { { pre = -, no= -, penalty = 10000 },  % (2)
   {}, % (3)
 }

The pattern (1) means ‘explicit hyphen followed by a dot’ (the braces around the dot prevent it from being interpreted as ‘any character’, as customary in regexps). The second argument reinserts the explicit hyphen with a penalty (2), and then retains the second char (the dot, 3). See Non–standard hyphenation with luatex.

0

If you frequently show prefixes, it's better to define a suitable command for them, so you can decide even at the last moment how to print them.

\documentclass[
  a4paper,
  openright,
  oneside,
  12pt,
]{memoir}
\usepackage{geometry}
\usepackage{fontspec}

\setmainfont{Linux Libertine O}

\newcommand{\prefix}[1]{\mbox{\textit{#1-}}}

\begin{document}

\subsubsection*{Original}

\noindent In (6.269), the first person pronoun \textit{wɨ} co-occurs with
the coreferential bound marker \textit{j-}. For Wayana, Tavares (2005: 413)
states that first and second person pronouns cannot occur in P position.


\subsubsection*{With macro}

\noindent In (6.269), the first person pronoun \textit{wɨ} co-occurs with 
the coreferential bound marker \prefix{j}. For Wayana, Tavares~(2005:~413) 
states that first and second person pronouns cannot occur in P~position.

\end{document}

Note the ties I inserted in order to avoid possible bad breaks.

enter image description here

You must log in to answer this question.

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