2

As my question hasn't been answered yet, I decided to rephrase it. I will try to simply the working example and specify my question.

I'm writing a dictionary that contains grammatical forms which are sometimes preceded by a dash, as you can see in the following example (right bottom of the page in the picture):

\documentclass[10pt, a4paper]{article}
\usepackage{lipsum}

\usepackage[a4paper, margin=3cm, driver=dvips]{geometry}

\usepackage{multicol}
\setlength{\columnsep}{45pt}

\usepackage[utf8]{inputenc}
\usepackage{tipa}
\usepackage[ngerman]{babel}

\begin{document}

\begin{multicols}{2}
\lipsum
\textbf{aham-turuk} umdrehen, umkehren, tauschen -teberuk, -toho, -teg, ahakey-toho, ahakey-roho, ahakey-moho-sumo, -uruk, -waruk, -teg, -toto, -tarum, -zug, -tuhouamanaratazam, -ratazamjok-limatahanan
\lipsum
\end{multicols}

\end{document}

typeset result

As you can see the initial dash of -zug sticks to the preceding line. I would like that dash to be "glued" to its host word. However, line break at the dash should generally still be available, in case of e.g. word-medial ocurrences, as in ahakey-toho.

Is there a way to globally specify, that word inital dashes should stick to their host word?

Thanks in advance!

L

Lucas
  • 65
  • You could write each in an mbox like so: \mbox{-toho} I think (have not tried as don't want to install tipa). As an aside why use tipa? - xelatex was invented for linguistics! In xelatex you could use a non-breakable font character given an appropriate font (U+2011). – Aubrey Blumsohn Sep 29 '15 at 10:35
  • Hey Aubrey, thx for your help. The dictionary got thousands of grammatical forms, so they are inserted into the document with a specific command to simplify formatting. I could use and \mbox on all of those (and I tried), however it also prevents hyphenation on forms with word-medial hyphen like ahakey-toho, as I cannot exclude those globally from the \mbox. Moreover, I need tipa for phonetic forms in the lexicon, and I would like to stick to pdflatex. I also want to avoid using special characters, since I wanna keep my input file relatively "clean" and consistent. – Lucas Sep 29 '15 at 10:53
  • @Lucas -- see my new comment on your previous question regarding notice to someone who has commented. – barbara beeton Sep 29 '15 at 13:18

3 Answers3

2

Define a command for an initial hyphen:

\documentclass[10pt, a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage{tipa}
\usepackage[ngerman]{babel}

\usepackage[a4paper, margin=3cm, driver=dvips]{geometry}

\usepackage{multicol}

\setlength{\columnsep}{45pt}

\newcommand{\ih}{\mbox{-}\nolinebreak\hspace{0pt}}

\begin{document}

\begin{multicols}{2}
\textbf{aham-turuk} umdrehen, umkehren, tauschen \ih teberuk, \ih toho, \ih teg,
  ahakey-toho, ahakey-roho, ahakey-moho-sumo, \ih uruk, \ih waruk, \ih teg,
  \ih toto, \ih tarum, \ih zug, \ih tuhouamanaratazam, \ih ratazamjok-limatahanan
\end{multicols}

%% alternative version
\renewcommand{\ih}{\mbox{-}}

\begin{multicols}{2}
\textbf{aham-turuk} umdrehen, umkehren, tauschen \ih teberuk, \ih toho, \ih teg,
  ahakey-toho, ahakey-roho, ahakey-moho-sumo, \ih uruk, \ih waruk, \ih teg,
  \ih toto, \ih tarum, \ih zug, \ih tuhouamanaratazam, \ih ratazamjok-limatahanan
\end{multicols}

\end{document}

The difference between the two versions is that the first allows hyphenation in the word after the hyphen, whereas the second one doesn't.

enter image description here

egreg
  • 1,121,712
  • This solution is perfect! This is exactly what I was looking for -- giving me a "glued" inital hyphen, without disabling usual hyphenation for other words. It was easy to quickly replace all inital dashes with the \ih command, using regex. Thanks a lot! – Lucas Oct 05 '15 at 09:30
1

As suggested by Aubrey, one or more words can be kept together on one line with the standard LaTeX command

\mbox{text}

which in your case would mean

... -tarum, \mbox{-zug}, -tuhouamanaratazam, ...

This and more info can be found here.

  • Hi Filippo, thanks a lot for your answer, but this is honestly not exactly what I was looking for. I am aware of the \mbox command, but as I am writing a dictionary with over 4 thousand of said forms, I'm looking for a way to globally specify that the inital hyphen should attach! I want to avoid manually applying commands to individual forms! – Lucas Sep 29 '15 at 11:51
  • @Lucas you presumably? are not writing the 4 thousand entries by hand? if you are generating the markup can you not generate it with \mbox in suitable places? – David Carlisle Sep 29 '15 at 12:44
  • ... or if it already written it will be a simple matter of searching and encasing all (space)-xxx(space) with sed or similar – Aubrey Blumsohn Sep 29 '15 at 15:01
  • Hey David and Aubrey. I have an .txt input file that contains all instances, and the dictionary uses a .sty stylefile. I could apply \mbox to all paradigm forms, as David suggests, but that would also result in making forms with word-medial hyphen unbreakable. If there is no other way, I guess I'll have to go back to what Aubrey suggests, and change the respective forms in the .txt using regex. Although this was what I wanted to avoid... Thx guys – Lucas Sep 30 '15 at 09:35
  • @Aubrey I tried it and put all dash-initial forms in an \mbox. However, now the problem I have is that longer forms starting with a dash exceed the column border, since hyphenation is prohibited by \mbox. So again, is there a way to "glue" the initial hyphen, but at the same time, still allow hyphenation of longer words? – Lucas Oct 01 '15 at 10:45
  • Honestly I thought there should be an easy way of doing this, as in defining in the preamble: if character left of - =0, then characters right of - have to be at least =2 before line break or something like this... – Lucas Oct 01 '15 at 11:09
  • Take a look at the url package. – Aubrey Blumsohn Oct 01 '15 at 11:17
  • What you are wanting is word breaks without hyphens. But what about your other words that are hyphenated - this must get really confusing. See http://tex.stackexchange.com/questions/26174/allow-line-break-but-without-inserting-a-dash – Aubrey Blumsohn Oct 01 '15 at 11:35
1

This is a proof of principle using the url package. I haven't time to iron out any glitches but some variant of this idea will work, bearing in mind the general issue of what a hyphen actually means in your document (see comments). This solution will just break the word without a hyphen if required after the initial hyphen.

\documentclass[10pt, a4paper]{article}
\usepackage[a4paper, margin=3cm, driver=dvips]{geometry}

\usepackage{multicol}
\setlength{\columnsep}{30pt}
\usepackage{url}
 \urlstyle{same}
\renewcommand{\UrlBreaks}{\do\.\do\@\do\\\do\/\do\!\do\_\do\|\do\;\do\>\do\]\do\)\do\,\do\?\do\'\do+\do\=\do\#\do\*\do\-\do\~\do\"\do\a\do\e\do\i\do\o\do\u\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0\do\b\do\c\do\d\do\f\do\g\do\h\do\j\do\k\do\l\do\m\do\n\do\p\do\q\do\r\do\s\do\t\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z}

\begin{document}

\begin{multicols}{2}
\textbf{aham-turuk} umdrehen, umkehren, tauschen \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, \url{-teberukdfgfdsgfdgfdgfg}, -toho, -teg, ahakey-toho, ahakey-roho, ahakey-moho-sumo, -uruk, -waruk, -teg, -toto, -tarum, -zug, -tuhouamanaratazam, -ratazamjok-limatahanan
\end{multicols}

\end{document}
  • thank you very much for your continued efford! This is a good solution! However, it is not perfect, as it breaks words that are hyphen inital, but unfortunately without applying a dash at the point of hyphenation. Therefore you get: -t(linebreak)beruk, when what you want is -t-(linebreak)beruk. Thank you! :) – Lucas Oct 05 '15 at 09:26