Text Formatting ⇒ Don't split words on certain letters
Don't split words on certain letters
I'm writing a document in latex. It's in my native language, Slovenian. And the rules for splitting words across multiple lines are a little bit different: the splitted word in new line should not start with letters: a,e,i,o,u and there are some other rules.
Is there any way to let Latex know about these rules? Does latex have a command, which can declare appropriate rules in any language, including Slovenian?
If not, how can I prevent Latex from splitting words on such letters. And I want a solution that affects whole document correctly, I don't want to mark each word separately.
Thanks
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Don't split words on certain letters
I recommend to use

Code: Select all
\usepackage[slovene]{babel}

You could implement your own special hyphenation rules using the
pre_linebreak_filter
callback (or a token_filter
callback) with 

\XeTeXinterchartoks
. In any way, you could insert \nobreak
commands.Stefan
Don't split words on certain letters
I'm already using:
Code: Select all
\usepackage[slovene]{babel}
Code: Select all
\documentclass[12pt,a4paper,openany]{book}\usepackage{fancyhdr}\usepackage{graphicx,epsfig}\usepackage[slovene]{babel}\usepackage{longtable}\usepackage[raggedrightboxes]{ragged2e}\begin{document}\chapter*{Testing}\begin{longtable}[l]{p{3.5cm}p{3.5cm}p{8cm}}\hline\textbf{Napad z vrinjenjem zlonamerne kode} & Cross-site scripting\newline XSS & Napad na spletno stran z vrinjenjem zlonamerne kode, napisane v skriptnem jeziku, npr. z namenom kraje piškotkov. \\\hline\end{longtable}\end{document}
Notice that the word "zlonamerne" is splitted on the 'a' boundary. The letter 'a' should not be put into the next line, but should be on the previous line or the word should be put into the new line alltogether.Napad na spletno stran z vrinjenjem zlon-
amerne kode, napisane v skriptnem jeziku,
npr. z namenom kraje pikotkov.
Any ideas?
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Don't split words on certain letters
Stefan
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Don't split words on certain letters
When I compile your example as is, I get the result pictured in the attachment.eleanor wrote:[…] When running pdflatex test.tex, the third column contains the following text:Notice that the word "zlonamerne" is splitted on the 'a' boundary. The letter 'a' should not be put into the next line, but should be on the previous line or the word should be put into the new line alltogether. […]Napad na spletno stran z vrinjenjem zlon-
amerne kode, napisane v skriptnem jeziku,
npr. z namenom kraje pikotkov.
- Attachments
-
- The obtained output of the provided example.
- hyphenation-slovene.png (12.97 KiB) Viewed 8289 times
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10