4

Why does not the hard hyphen “‑” work in lualatex with the package luainputenc with option utf8? With hard hyphen, I mean a hyphen, which prohibits the line to break directly after it.

MWE:

\documentclass{article}

\usepackage[utf8]{luainputenc}

\begin{document}
Åsa‑Nisse
\end{document}
1
  • 1
    Do not use luainputenc, use utf8 encoded files and fontspec. See my answer
    – MaxNoe
    Oct 16, 2014 at 21:54

2 Answers 2

7

luainputenc doesn't define a conversion for U+2011 (NON-BREAKING HYPHEN); you can do it yourself:

\documentclass{article}

\usepackage[utf8]{luainputenc}
\DeclareUnicodeCharacter{2011}{\mbox{-}}

\begin{document}
Åsa‑Nisse
\end{document}

enter image description here

1
  • Or, as I would prefer, just use \mbox in those few instances where you don't want a break to occur with names such as "Åsa-Nisse".
    – Sverre
    Oct 16, 2014 at 17:21
5

Use of luainputenc is deprecated. The documentation of luainputenc itself says:

Input encoding management for LuaTEX, needed only for compatibility with old documents. For new documents, using UTF-8 encoding and Unicode fonts is strongly recommended. You’ve been warned!

UTF-8 support works out of the box with lualatex and fontspec if your files are utf8 encoded.

\documentclass{article}

\usepackage{fontspec}

\begin{document}
    Åsa‑Nisse
\end{document}

Now to your question: use the package extdash: \usepackage[shortcuts]{extdash}. This should be the last package you include, even after hyperref and bookmark.

documentation

You can then use the \=/ command to indicate a non-breakable hyphen, the \== to indicate a non-breakable en-dash (--):

\documentclass{article}

\usepackage{fontspec}

% lots of packages here

% these are usually the last packages to load:
\usepackage[unicode]{hyperref}
\usepackage{bookmark}
% very last package:
\usepackage[shortcuts]{extdash}

\begin{document}
    Åsa\=/Nisse
    Maxwell\==Boltzmann\=/Deviation
    $x$\=/axis
\end{document}

If a word is a compound with hyphen, LaTeX by default only breaks at this hyphen, not at normally breakable places inside the words. extdash also deals with this problem. Of you use the commands \-/ for a hyphen or \-- for an en-dash LaTeX is also allowed to break inside of the words.

7
  • 1
    This should probably be a comment, not an answer, since it doesn't answer the OP's question.
    – Sverre
    Oct 16, 2014 at 19:38
  • Ill add the answer
    – MaxNoe
    Oct 16, 2014 at 19:39
  • I would normally user fontspec but I need to use “standard” fonts.
    – MunHo
    Oct 17, 2014 at 12:15
  • Latin Modern should be the standard font and is the feault font that fontspec is loading
    – MaxNoe
    Oct 17, 2014 at 12:57
  • why do u need to use and what do you mean by standard fonts?
    – MaxNoe
    Oct 17, 2014 at 17:26

You must log in to answer this question.

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