4

I'm writing the thesis in Polish language and one of our typography rule is that there can't be single letter at the and of line, like (w and i):

Tomek poszedl do sklepu w % <-- not allowed
mieście, żeby kupić jabłka i % <-- not allowed
bułki

I'm using LaTeX and the solution proposed by @topskip in this post:

one-letter word at the end of line

produce multiple errors during compliation. Additionaly, this content was posted few yeras ago. So I'm wondering is there any new tip that can solve my problem?

barnaba
  • 75
  • Lua(La)TeX changed 'recently'. Most likely you need \usepackage{luatex85} (and other remedies ;-)) –  Dec 27 '16 at 22:37
  • See http://tex.stackexchange.com/questions/46955/is-there-way-to-put-hard-space-after-defined-words/98826#98826. In my answer you must disable macros before new section. But you will not problems in reading comments, because they are in Polish. – Przemysław Scherwentke Dec 27 '16 at 23:17
  • I updated the title of the question. I hope that's ok for you. I think the new title is more accurate and Google-friendlier. – Dr. Manuel Kuehner Dec 28 '16 at 00:03

3 Answers3

4

You are using LaTeX (i guess pdflatex) and not LuaTeX which was used in the referred solution. Am I right?


Before You Start Your Thesis / Document

Following the LaTeX wikibook (link) about the internationalization in the case of Polish:

Polish has many single letter connectives [...] To ensure that LaTeX won't set them as last letter in the line, you have to use non breakable space [...]

i~słodka
a~także
i~ciała
i~Basi

So the solution is to simply connect the following word with a ~ (tilde, also known as a non breakable space).

The non breakable space feature of the tilde character is a core LaTeX feature (thanks at @DavidCarlisle).


By the way, I googled for polish single letter latex and the solution was the third entry in my hit list.


When You Have Already Finished Your Document

Maybe you can use a text editor like Notepad++ (https://notepad-plus-plus.org/) and search and replace _z_, and _w_ and so on with _z~, and _w~ and so on (with _ I want to indicate a space).

Notepad++ also can search and replace in multiple files at once. Be sure that you try it on a backup copy of your actual document!

enter image description here

With regular expressions you may be able to have even more sophisticated ways. But I do not know much about that.

  • Yes you are right, I am using LaTeX, precisely pdflatex. I know this solution, but when the thesis has more than 50 pages it becomes quite exhausting to straighten up all the single letters at the end of line. – barnaba Dec 27 '16 at 22:58
  • @barnaba At least the solution will help others which are about to start writing. Maybe you can use an text editor like notepad++ (https://notepad-plus-plus.org/) and search and replace "space"z"space", and "space"w"space" and so on with "space"z~, and "space"w~ and so on. – Dr. Manuel Kuehner Dec 27 '16 at 23:01
  • ~ is core latex (and plain tex) not babel – David Carlisle Dec 27 '16 at 23:05
  • @DavidCarlisle Thanks for the clarification. I updated my answer accordingly. – Dr. Manuel Kuehner Dec 27 '16 at 23:17
  • Thank you @Dr. Manuel Kuehner, for me that's the easiest and the quickest solution, and what is the most important it works perfectly! – barnaba Dec 27 '16 at 23:58
1

here's a command I used for this (I had several .tex files to modify):

find -name "*.tex" -exec sed -i 's/\( [^0-9\| ]\) \([^\|]\)/\1~\2/g' {} \;

It adds non-breakable space after a single character in between spaces that is not a number, a pipe or a space itself.

0

With the latest version of babel (3.58) with luatex there is predefined ‘transform’ for this purpose (also available in Czech and Slovak):

\documentclass{article}

\usepackage[polish]{babel}

\babelprovide[transforms = oneletter.nobreak]{polish}

\begin{document}

\hsize=1pt

Tomek poszedl do sklepu w % <-- not allowed mieście, żeby kupić jabłka i % <-- not allowed bułki

\end{document}

Polish one letter no break

Javier Bezos
  • 10,003