LaTeX forum ⇒ Text FormattingDon't split words on certain letters

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
eleanor
Posts: 19
Joined: Sat Oct 03, 2009 6:03 pm

Don't split words on certain letters

Postby eleanor » Sun Jul 29, 2012 10:57 pm

Hi,

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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
Stefan Kottwitz
Site Admin
Posts: 7804
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sun Jul 29, 2012 11:37 pm

Hi Eleanor,

I recommend to use babel:
  1. \usepackage[slovene]{babel}

or polyglossia, the latter with XeTeX.

You could implement your own special hyphenation rules using the pre_linebreak_filter callback (or a token_filter callback) with LuaTeX. Or, with XeTeX, your could use \XeTeXinterchartoks. In any way, you could insert \nobreak commands.

Stefan
Site admin

Link:
BBcode:
HTML:
Hide post links
Show post links

eleanor
Posts: 19
Joined: Sat Oct 03, 2009 6:03 pm

Postby eleanor » Mon Jul 30, 2012 12:24 am

Hi, thanks for quick reply.

I'm already using:
  1. \usepackage[slovene]{babel}


And from your answer I guess, this should be enough. But it isn't. The words are still splitted wrongly. A small example is the following code:
  1. \documentclass[12pt,a4paper,openany]{book}
  2. \usepackage{fancyhdr}
  3. \usepackage{graphicx,epsfig}
  4. \usepackage[slovene]{babel}
  5. \usepackage{longtable}
  6. \usepackage[raggedrightboxes]{ragged2e}
  7.  
  8.  
  9. \begin{document}
  10. \chapter*{Testing}
  11. \begin{longtable}[l]{p{3.5cm}p{3.5cm}p{8cm}}
  12. \hline
  13. \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
  14. \end{longtable}
  15.  
  16. \end{document}


When running pdflatex test.tex, the third column contains the following text:
Napad na spletno stran z vrinjenjem zlon-
amerne kode, napisane v skriptnem jeziku,
npr. z namenom kraje pikotkov.


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.

Any ideas?

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
Stefan Kottwitz
Site Admin
Posts: 7804
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Jul 30, 2012 12:26 am

Sure, the other ideas I listed above. Perhaps have a look at the links to XeTeX and LuaTeX, to evaluate if it's worth working it out.

Stefan
Site admin

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Mon Jul 30, 2012 9:30 am

eleanor wrote:[…] When running pdflatex test.tex, the third column contains the following text:
Napad na spletno stran z vrinjenjem zlon-
amerne kode, napisane v skriptnem jeziku,
npr. z namenom kraje pikotkov.


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. […]

When I compile your example as is, I get the result pictured in the attachment.
Attachments
hyphenation-slovene.png
The obtained output of the provided example.
hyphenation-slovene.png (12.97 KiB) Viewed 934 times
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Text Formatting”

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests