强调单词的一部分时断开连字符

强调单词的一部分时断开连字符

我正在用法语写一本关于谐音。这本书应该有两部分,一部分是正常的,另一部分是通过强调部分单词给出解决方案。

似乎有时文字会超出文本主体的范围。我主要注意到 EBGaramond 字体(我想使用)会出现这种情况,但默认字体(Computer Modern)不会出现这种情况。

加拉蒙德 默认

以下是 MWE:

\documentclass[12pt]{article}

\usepackage[english,francais]{babel}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{xstring}
\usepackage{ebgaramond}

\newcommand{\s}[1]{\IfStrEq{~}{#1}{}{#1}}
\newcommand{\scol}[1]{%
  \begingroup%
  \color{red}{%
    \IfStrEq{~}{#1}%
            {\textbf{\textperiodcentered}}%
            {#1}%
  }%
  \endgroup%
}%

%http://connect.lulu.com/t5/Mise-en-page-du-corpus/Comment-faire-pour-que-mon-contenu-s-%C3%A9tale-jusqu-aux-bords-de-la/ta-p/33461
\usepackage[
  showframe,
  % Digest
  paperwidth=13.97cm,
  paperheight=21.59cm,
  bindingoffset=0.625in,
  hmargin={0.0in,0.5in},
  vmargin={0.5in,0.5in},
  includeall, nomarginpar, twoside,
  ignorehead=false, ignorefoot=false, ignoremp=false,
  headsep=0.5em,
  footskip=1.2em,
]{geometry}

\usepackage{layout}

\setlength{\parindent}{0pt}

\newcommand{\aspoonerism}{%
  An English one:\\
  You have \s{~}hissed all my \s{m}ystery lectures. You have \s{t}asted a whole
  \s{w}orm. Please leave Oxford on the next \s{t}own \s{d}rain.

  A French one:\\
  \textsc{Lecteurs}: \og{}\s{A}cculons ces hommes d'\s{en}fer \s{fêl}és rêvant de
  \s{radicalis}ation!\fg{}
}%

\begin{document}

\section{Spoonerism}
\aspoonerism
\section{Solutions}
\renewcommand{\s}{\scol}
\aspoonerism

\end{document}

当然,我可以使用\-诸如:之类的方法强制使用连字符\s{radicalis}a\-tion,并使其正常工作。但这不是解决方案,因为如果我更改纸张宽度,我将不得不重新连字符所有单词,这是一项艰巨的任务,并降低了 tex 代码的可读性。

在此处输入图片描述

在这种情况下,有没有简单的解决方案可以使连字符发挥作用?

谢谢

编辑:

在通过 LuaLaTeX 运行源代码后,连字符是正确的,但论文不正确。我没有在geometry包中看到任何限制。但我发现了这个http://tug.org/pipermail/tex-live/2016-May/038560.html

事实上,我想使用支持彩色文本和连字符以及 OTF 字体的 TeX。

在此处输入图片描述

编辑2:

详见https://www.tug.org/pipermail/luatex/2016-May/005906.htmlTexLive 2016 有一个错误。因此添加\usepackage{luatex85}有帮助。

编辑3:

使用\usepackage{ebgaramond}似乎有效。但如果我切换到fontspec创建假粗体字体,我仍然会遇到问题:

\setmainfont[
  Numbers=Lining,
  Scale=1.00,
  Extension=.otf,
  Ligatures = TeX ,
  UprightFont    = *-Regular,
  ItalicFont     = *-Italic,
  BoldItalicFont = *-Italic,
  BoldItalicFeatures = {FakeBold=3},
  ,]{EBGaramond12}%

编辑4

我使用 lualatex 来处理这个问题:

\documentclass[12pt]{book}

\usepackage{luatex85}
\usepackage[english,francais]{babel}
\usepackage{xcolor}
\usepackage{xstring}
\usepackage{ebgaramond}

\newcommand{\s}[1]{\IfStrEq{~}{#1}{}{#1}}
\newcommand{\scol}[1]{%
  \begingroup%
  \color{red}{%
    \IfStrEq{~}{#1}%
        {\textbf{\textperiodcentered}\nobreak\hspace{0pt}}%
            {#1}%
  }%
  \endgroup%
}%
\usepackage[
  showframe,
  % Digest
  paperwidth=13.97cm,
  paperheight=21.59cm,
  bindingoffset=0.625in,
  hmargin={0.0in,0.5in},
  vmargin={0.5in,0.5in},
  includeall, nomarginpar, twoside,
  ignorehead=false, ignorefoot=false, ignoremp=false,
  headsep=0.5em,
  footskip=1.2em,
]{geometry}


\setlength{\parindent}{0pt}

\newcommand{\aspoonerism}{
  \og{}Ma quen\s{e}lle n'est jamais r\s{u}de!\fg{} Le \s{ch}icaneur
  fa\s{r}aud exhibe sa quene\s{ll}e ho\s{nn}ie, quenelle d'un ty\s{p}e trop
  fri\s{qu}é, et se tord le \s{c}ou en \s{b}afouillant. Faut-il saisir le
  gredin fou de quenelles ou faire cesser pendant plus d'une minute ce comique
  haineux qui parle de paix à de gros nases\s{~} au petit Q\s{I}?
  }


\begin{document}
\section{spoonerism}
\aspoonerism
\section{solution}
\renewcommand{\s}{\scol}
\aspoonerism
\end{document}

但还是没用。仍然没有任何可行的解决方案。

完整日志为:

This is LuaTeX, Version 0.95.0 (TeX Live 2016)
 restricted system commands enabled.
(./m.tex
LaTeX2e <2016/03/31>
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/book.cls
Document Class: book 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/bk12.clo))
(/usr/local/texlive/2016/texmf-dist/tex/generic/luatex85/luatex85.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/babel/babel.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/babel/luababel.def)
(/usr/local/texlive/2016/texmf-dist/tex/generic/babel-english/english.ldf
(/usr/local/texlive/2016/texmf-dist/tex/generic/babel/babel.def
(/usr/local/texlive/2016/texmf-dist/tex/generic/babel/luababel.def)))
(/usr/local/texlive/2016/texmf-dist/tex/generic/babel-french/frenchb.ldf
(/usr/local/texlive/2016/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-fr.
tex UTF-8 French hyphenation patterns
(/usr/local/texlive/2016/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-fr.
tex)
(/usr/local/texlive/2016/texmf-dist/tex/generic/hyph-utf8/patterns/quote/hyph-q
uote-fr.tex))))
(/usr/local/texlive/2016/texmf-dist/tex/latex/carlisle/scalefnt.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(/usr/local/texlive/2016/texmf-dist/tex/lualatex/luatex-def/luatex.def
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/local/texlive/2016/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/xstring/xstring.tex))
(/usr/local/texlive/2016/texmf-dist/tex/latex/ebgaramond/ebgaramond.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2016/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/textcomp.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2016/texmf-dist/tex/luatex/luaotfload/luaotfload.sty(using
write cache: /Users/renard/Library/texlive/2016/texmf-var/luatex-cache/generic)
(using read cache: /usr/local/texlive/2016/texmf-var/luatex-cache/generic /User
s/renard/Library/texlive/2016/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.137 seconds)
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu2enc.def)
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu2lmr.fd)(compiling luc: /
usr/local/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regul
ar.luc)(load luc: /Users/renard/Library/texlive/2016/texmf-var/luatex-cache/gen
eric/fonts/otl/lmroman10-regular.luc))(compiling luc: /usr/local/texlive/2016/t
exmf-var/luatex-cache/generic/fonts/otl/lmroman12-regular.luc)(load luc: /Users
/renard/Library/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmroman12
-regular.luc)
(/usr/local/texlive/2016/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3enc.def(compiling luc: /us
r/local/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmromanslant12-re
gular.luc)(load luc: /Users/renard/Library/texlive/2016/texmf-var/luatex-cache/
generic/fonts/otl/lmromanslant12-regular.luc)(compiling luc: /usr/local/texlive
/2016/texmf-var/luatex-cache/generic/fonts/otl/lmroman12-italic.luc)(load luc:
/Users/renard/Library/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmr
oman12-italic.luc)(compiling luc: /usr/local/texlive/2016/texmf-var/luatex-cach
e/generic/fonts/otl/lmroman12-bold.luc)(load luc: /Users/renard/Library/texlive
/2016/texmf-var/luatex-cache/generic/fonts/otl/lmroman12-bold.luc)
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu2lmss.fd)(compiling luc:
/usr/local/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmsans12-regul
ar.luc)(load luc: /Users/renard/Library/texlive/2016/texmf-var/luatex-cache/gen
eric/fonts/otl/lmsans12-regular.luc))
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-cfg/graphics.cfg))))
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.cfg)))(compilin
g luc: /usr/local/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/ebgaram
ond12-regular.luc)(load luc: /Users/renard/Library/texlive/2016/texmf-var/luate
x-cache/generic/fonts/otl/ebgaramond12-regular.luc)(compiling luc: /usr/local/t
exlive/2016/texmf-var/luatex-cache/generic/fonts/otl/ebgaramond12-italic.luc)(l
oad luc: /Users/renard/Library/texlive/2016/texmf-var/luatex-cache/generic/font
s/otl/ebgaramond12-italic.luc)(compiling luc: /usr/local/texlive/2016/texmf-var
/luatex-cache/generic/fonts/otl/ebgaramondinitials.luc)(load luc: /Users/renard
/Library/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/ebgaramondinitia
ls.luc)) (/usr/local/texlive/2016/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ifvtex.sty)) (./m.aux)
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3cmr.fd)
(/usr/local/texlive/2016/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2016/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/local/texlive/2016/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/luatex-loader.sty
(/usr/local/texlive/2016/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua)))
(/usr/local/texlive/2016/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/atbegshi.sty)
Overfull \hbox (9.63983pt too wide) in paragraph at lines 52--53
[]\EU2/EBGaramond12(0)/bx/n/12 « Ma quen[]e[]lle n’est ja-mais r[]u[]de !
» Le []ch[]ica-neur fa[]r[]aud ex-hibe sa quene[]ll[]e
[1{/usr/local/texlive/2016/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./m.aux))
(see the transcript file for additional information)
 572 words of node memory still in use:
   4 hlist, 1 vlist, 1 rule, 14 glue, 1 penalty, 34 attribute, 53 glue_spec, 9
attribute_list, 1 write nodes
   avail lists: 2:340,3:31,4:29,5:36,6:571,7:181,8:9,9:33,10:2,11:41
</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/ebgaramond/EBGaramond
12-Regular.otf></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/ebgara
mond/EBGaramond12-Italic.otf>
Output written on m.pdf (1 page, 11328 bytes).
Transcript written on m.log.

在此处输入图片描述

相关内容