# LuaLaTeX vs XeLaTeX hyphenation and line layout [closed]

I am typesetting my journal just for the fun of it. I am using KOMA-script's scrartcl with two columns. I am testing with both LuaLaTeX and XeLaTeX. I haven noticed page count is different between the two renderings with more pages rendered by XeLaTeX, 116 vs 114 A5 pages. I have noticed there is a difference in how the two engines hyphenate. Here is an example from my list of figures:

As you can see, XeLaTeX has decided to hyphenate the word "démoni" but as a result there is this gaping hole on the 3rd line. The picture above is an extreme example but overall the LuaLaTeX result seems to contain less such holes than the XeLaTeX result.

OTOH, elsewhere (on the same page, actually) LuaLaTeX hyphenated first three consecutive lines of a 4 line paragraph, which does not seem ideal either, while XeLaTeX chose to hyphenate only first two consecutive lines.

• Are such huge differences expected? Can anyone describe or link me to description of these differences?
• Is there a way to bring the results from the two engines closer together?

Not a MWE, just the preamble of my document here. It is a modified version of what Pandoc produces for conversion into LaTeX:

\documentclass[czech,twoside]{scrartcl}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage{bookmark}
\hypersetup{unicode=true,
pdfborder={0 0 0},
\urlstyle{same}  % don't use monospace font for urls
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,main=czech]{babel}
\else
\usepackage{polyglossia}
\setmainlanguage[]{czech}
\fi
\usepackage{listings}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[perpage,titleref,savepos,counter,user]{zref}
\usepackage{amssymb}
\usepackage{newunicodechar}
\usepackage{accsupp}
\usepackage{MnSymbol}
\usepackage{textcomp}
\usepackage{etoolbox}
\usepackage{csquotes}
\DeclareQuoteAlias{german}{czech}
\usepackage{float}
\usepackage{dblfloatfix}
\usepackage[font={slshape},leftmargin=0.5\leftmargin,rightmargin=0.5\rightmargin]{quoting}

\setmainfont{Charis SIL}
\setsansfont{TeX Gyre Heros}
\setmonofont{Droid Sans Mono}

\newfontfamily\myurlfont[Numbers=OldStyle,Ligatures={TeX,Common}]{Roboto Condensed}
\renewcommand\UrlFont{\myurlfont}

\tolerance 5000

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[ro]{\leftmark}

\fancyfoot[re]{\leftmark}

\fancyfoot[ce,co]{\thepage}

\renewcommand{\headrulewidth}{1pt} %0pt for no rule, 2pt thicker etc...
\renewcommand{\footrulewidth}{1pt}

\makeatletter
\zref@newprop{sectiontitle}{}
\newcommand*{\currentsectiontitle}{\zref@getcurrent{sectiontitle}}
\newcommand*{\mysectionmark}[1]{%
\zref@setcurrent{sectiontitle}{#1}%
\markboth{\uppercase{#1}}{\uppercase{#1}}}
\makeatother

\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{}

\AtBeginEnvironment{quote}{\slshape}

\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>0.90\linewidth0.90\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>0.85\textheight0.85\textheight\else\Gin@nat@height\fi}
\makeatother

% This makes sure that linked text's links shows as a footnote.
\makeatletter
\let\oldhref=\href
\newcommand\hreffootnote[2]{\oldhref{#1}{#2}\footnote{\url{#1}}}
%\DeclareRobustCommand{\hreffootnote}{\hyper@normalise\hreffootnote@}
\makeatother

\PassOptionsToPackage{backref}{hyperref}

\newcommand{\noncopy}[1]{%
\BeginAccSupp{method=escape,ActualText={}}%
#1%
\EndAccSupp{}%
}

\lstset{breaklines=true,
xleftmargin=1.5em,framexleftmargin=1em,
basicstyle=\ttfamily,
upquote=true,
literate={}{{\BeginAccSupp{method=plain,ActualText=}‵\EndAccSupp{}}}1
{"}{{\BeginAccSupp{method=plain,ActualText="}"\EndAccSupp{}}}1
{'}{{\BeginAccSupp{method=plain,ActualText='}'\EndAccSupp{}}}1,
showstringspaces=false,
numbers=left, numberstyle=\scriptsize\noncopy,
postbreak=\raisebox{0ex}[0ex][0ex]{\noncopy{\ensuremath{\color{red}\hookrightarrow}}},
prebreak=\raisebox{0ex}[0ex][0ex]{\noncopy{\ensuremath{\color{red}\rhookswarrow}}}}

% This allows line breaks in URL in more places.
\def\UrlBreaks{\do\/\do-\do.\do=\do_\do?\do\&\do\%\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\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\do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9}

\title{Deníček}
\author{Václav Haisman}

\date{}


## closed as unclear what you're asking by Keks Dose, Martin Schröder, Svend Tveskæg, Andrew, user31729 Mar 5 '16 at 14:15

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• microtype can make a big difference: xelatex can't do font expansion. – Ulrike Fischer Feb 27 '16 at 13:16
• Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – Martin Schröder Feb 28 '16 at 23:23