2

I use the \nobreakdash command to disallow a linebreak after the dash in short expressions like -s, -ar etc. I use ({\nobreakdash}-s, {\nobreakdash}-ar) but it seems not work as can be seen on the picture below.

enter image description here

Here comes minimul example:

\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
  • 4
    \nobreakdash needs to see how many - tokens follow it; with your usage a closing brace is following, so \nobreakdash does nothing. Remove the braces.
    – egreg
    Oct 25, 2012 at 6:49

1 Answer 1

6

Don't surround \nobreakdash with braces.

\documentclass{article}

\usepackage{amsmath}

\textwidth=50pt

\begin{document}

aaaaaa {\nobreakdash}-bbb% incorrect

aaaaaa \nobreakdash-bbb% correct

\end{document}

enter image description here

EDIT: Your added example was anything but minimal, but I was able to track down the culprit: \usepackage[czech]{babel} makes the hyphen (-) an active character, which seems to break \nobreakdash. Solution/workaround: Replace \nobreakdash- with \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}

enter image description here

6
  • I have tried to type (\nobreakdash-s, \nobreakdash-ar) but with no improvement. Is this correct typing?
    – chejnik
    Oct 25, 2012 at 6:59
  • @chejnik Compile my example as-is -- does it work for you? If yes, you must be doing something different in your actual document.
    – lockstep
    Oct 25, 2012 at 7:17
  • 1
    Yes, it works for me. I am afraid that minimal example is too long though. Here is one entry line, maybe it will serve well - \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}}.} Thank you
    – chejnik
    Oct 25, 2012 at 7:27
  • @chejnik I can't see an "obvious" mistake in your code snippet (changing colors shouldn't be a problem). You will have to provide a small, compilable example that shows the problematic behaviour.
    – lockstep
    Oct 25, 2012 at 7:33
  • 2
    [czech]{babel} is known for this mal-function. It should definitely be manually reverted.
    – yo'
    Oct 25, 2012 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.