\nobreakdash 与 babel 不兼容

\nobreakdash 与 babel 不兼容

我使用\nobreakdash命令来禁止在短表达式(如 -s、-ar 等)后换行。我使用({\nobreakdash}-s, {\nobreakdash}-ar),但它似乎不起作用,如下图所示。

在此处输入图片描述

下面是最小的例子:

\documentclass[10pt,a4paper,twocolumn]{extbook}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage[top=2cm, headsep=0.4cm, bottom=1.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage{fancyhdr}
\usepackage[icelandic, latin, czech]{babel}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{00A0}{~} % finds hidden non-breakable space
\usepackage[T1]{fontenc}
\usepackage{tgpagella}
\usepackage[scaled=0.90]{helvet} % ss
\usepackage{hanging}
\usepackage{makeidx}
\usepackage{tipa}
\usepackage{fix2col}
\usepackage{color}
\usepackage{titlesec}
\usepackage{amsmath} %used for non-breakabledash
\usepackage{hyphenat} % no hyphen in abbreviations

 % COLORS
\definecolor{darkgreen}{rgb}{0.4, 0.01, 0.24}

%COMMANDS
\newcommand\entry[3][]{\hangpara{2em}{1}{\fontfamily{phv}\selectfont{\textbf{{#2}}}}\ 
#3\ifx\relax#1\relax\markboth{#2}{#2}\else\markboth{#1}{#1}\fi
\par}\nopagebreak[4]

  \newcommand\n{$n$\nobreakdash-\hspace{0pt}} %nonbreakable dash in grammar endings
  \def \nobreakseq {\nobreak \hskip 0pt \hbox} %nolinebreak in case like (-s, -)

 % DICTIONARY PAGE STYLE
 \fancypagestyle{dictstyle}{%
 \renewcommand{\headrulewidth}{0.4pt}
 \fancyhf{}
 \fancyhead[LE,LO]{{\fontfamily{phv}\selectfont{\textbf{\rightmark}}}}
 \fancyhead[CO,CE]{\thepage}%the page numbers will be printed when the dictionary is ready
 \fancyhead[RE,RO]{{\fontfamily{phv}\selectfont{\textbf{\leftmark}}}}}

 \setlength{\columnsep}{20pt}
 \setlength{\columnseprule}{0.1pt}

  \newcommand{\HRule}{\rule{\linewidth}{0.1mm}} % rule line

 \begin{document}
 \twocolumn
 \pagestyle{dictstyle}

  \entry[stjórnmálafræðingur]{{stjórn$\cdot$mála$\cdot$$\cdot$fræðing|ur}}{{\textipa{[{s}{\textsubring{d}}{j}{ou}{r}{\textsubring{d}}{\textsubring{n}}{m}{au}{l}{a}{f}{r}{a}{i}{ð}{i}{\ng}{\r{g}}{\textscy}{\textsubring{r}}]}}{\color{darkgreen}{\small{\textbf{  m}}}}{\color{darkgreen}{\footnotesize{ (\nobreakdash-s, \nobreakdash-ar)}}}\foreignlanguage{czech}{{ politolog, politoložka}}.}

 \end{document}

答案1

不要\nobreakdash用括号括起来。

\documentclass{article}

\usepackage{amsmath}

\textwidth=50pt

\begin{document}

aaaaaa {\nobreakdash}-bbb% incorrect

aaaaaa \nobreakdash-bbb% correct

\end{document}

在此处输入图片描述

编辑:您添加的示例绝不是最小的,但我能够找到罪魁祸首:\usepackage[czech]{babel}使连字符 ( -) 成为活动字符,这似乎会破坏\nobreakdash。解决方案/解决方法:替换\nobreakdash-\hbox{-}

\documentclass{article}

\usepackage[czech]{babel}

\usepackage{amsmath}

\textwidth=50pt

\begin{document}

aaaaaa {\nobreakdash}-bbb% incorrect

aaaaaa \nobreakdash-bbb% correct, but doesn't work for czech

aaaaaa \hbox{-}bbb% workaround for czech

\end{document}

在此处输入图片描述

相关内容