I am writing a double-columned dictionary using a quite complex style-file and an external input-file. However, in order to illustrate my problem, I simplified my template, yet incorporated my entire preamble (excluding the cmd for using my style-file of course).
My Problem: The dictionary contains hyphen-initial words, which are grammatical roots listed in the lexicon. This is probably relatively unusual. I already read about hyphenation problems with compound words containing hyphens; well, let me tell you hyphen-initial words are a pain in the neck:
\documentclass[10pt, a4paper]{article}
\setcounter{secnumdepth}{0} % sections are level 1
\usepackage{lipsum}
\usepackage[a4paper, margin=3cm, driver=dvips]{geometry}
%twocolumn, columnsep=25pt,
\usepackage{multicol}
\setlength{\columnsep}{45pt}
%\setlength{\columnseprule}{1.5pt}
\usepackage[utf8]{inputenc}
\usepackage{tipa}
\usepackage[ngerman]{babel}
%\usepackage{dict}%use the style file
\newcommand*\justify{%
\fontdimen2\font=0.4em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
\hyphenchar\font=`\-% allowing hyphenation
}
\usepackage{paralist}%for the \compactdesc environment
\usepackage{tgtermes}
\usepackage{pdfpages}
%\usepackage{minipage}
\usepackage{fancyhdr} % Required for modifying headers and footers
\fancyhead[L]{{\rightmark}} % Top left header
\fancyhead[R]{{\leftmark}} % Top right header
\renewcommand{\headrulewidth}{.5pt} % Rule under the header
\fancyfoot[C]{\vspace{2em}\textbf{{\thepage}}} % Bottom center footer
\renewcommand{\footrulewidth}{.5pt} % Rule under the footer
\pagestyle{fancy} % Use the custom headers and footers throughout the document
\setdefaultleftmargin{1em}{}{}{}{}{}
%for illustrations
\usepackage{pstricks}
\psset{arrows=c-c}
\usepackage{overpic}
\usepackage{graphicx}
\newlength\cus
\sloppy
%for dotfills in the table of contents
\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@section}
{\hfil}
{\leaders\hbox{\normalfont$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill}
{}{}
\makeatother
\usepackage[hidelinks]{hyperref}
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}} % Horizontal rule definition
\begin{document}
\begin{multicols}{2}
\lipsum
\textbf{aham-turuk} umdrehen, umkehren, tauschen \texttt{ -teberuk, -toho, -teg, ahakey-toho, ahakey-roho, ahakey-moho-sumo, -uruk, -waruk, -teg, -toto, -tarum, -zug, -tuhouamanaratazam, -tuhouamanaratazamjoklimatahanan}
\lipsum
\end{multicols}
\end{document}
As you can see in my example above, the hyphen-initial root forms (in \texttt -- which they HAVE to be in!) create some problems in terms of line breaking and word alignment. After reading about similar problems, I tried the \justify command, which produces another problem: The hyphens are separated from their host word, as you can see below:
\documentclass[10pt, a4paper]{article}
\setcounter{secnumdepth}{0} % sections are level 1
\usepackage{lipsum}
\usepackage[a4paper, margin=3cm, driver=dvips]{geometry}
%twocolumn, columnsep=25pt,
\usepackage{multicol}
\setlength{\columnsep}{45pt}
%\setlength{\columnseprule}{1.5pt}
\usepackage[utf8]{inputenc}
\usepackage{tipa}
\usepackage[ngerman]{babel}
%\usepackage{dict}%use the style file
\newcommand*\justify{%
\fontdimen2\font=0.4em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
\hyphenchar\font=`\-% allowing hyphenation
}
\usepackage{paralist}%for the \compactdesc environment
\usepackage{tgtermes}
\usepackage{pdfpages}
%\usepackage{minipage}
\usepackage{fancyhdr} % Required for modifying headers and footers
\fancyhead[L]{{\rightmark}} % Top left header
\fancyhead[R]{{\leftmark}} % Top right header
\renewcommand{\headrulewidth}{.5pt} % Rule under the header
\fancyfoot[C]{\vspace{2em}\textbf{{\thepage}}} % Bottom center footer
\renewcommand{\footrulewidth}{.5pt} % Rule under the footer
\pagestyle{fancy} % Use the custom headers and footers throughout the document
\setdefaultleftmargin{1em}{}{}{}{}{}
%for illustrations
\usepackage{pstricks}
\psset{arrows=c-c}
\usepackage{overpic}
\usepackage{graphicx}
\newlength\cus
\sloppy
%for dotfills in the table of contents
\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@section}
{\hfil}
{\leaders\hbox{\normalfont$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill}
{}{}
\makeatother
\usepackage[hidelinks]{hyperref}
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}} % Horizontal rule definition
\begin{document}
\begin{multicols}{2}
\lipsum
\textbf{aham-turuk} umdrehen, umkehren, tauschen \texttt{\justify -teberuk, -toho, -teg, ahakey-toho, ahakey-roho, ahakey-moho-sumo, -uruk, -waruk, -teg, -toto, -tarum, -zug, -tuhouamanaratazam, -tuhouamanaratazamjoklimatahanan}
\lipsum
\end{multicols}
\end{document}
I tried disabling \hyphenchar\font=`-% allowing hyphenation in the preamble, with the result that hyphen-internal words (like ahakey-moho-sumo) become unbreakable and produce overfull boxes.
Is there a way, to produce a text with the hyphen-initial forms in \texttt with correct spacing and attached hyphen? I tried toying around with the extdash package, but haven't had much luck.
Help me please!
\fontdimen<number><font>and\hyphenchar<font>are global. – egreg Sep 18 '15 at 12:38\command{...}wrapper (keeping both commas and spaces out of the wrapper)? if so, then i think the other problems are tractable. – barbara beeton Sep 18 '15 at 17:13