1

I have found that with XeTeX and fontspec package using the following value

{\addfontfeature{LetterSpace=15em plus.1em minus.1em}

instead of e.g.

{\addfontfeature{LetterSpace=15} 

it gives good results as in this way the lines never cross the margin.

I would ask if there is a way to define a key for that value so I could avoid to write it every time. For example, I would obtain something similar of what it does the microtype package, where you can define the spacing value in the preamble and then just write \textls{textspaced} to apply it.

Thank you!

EDIT:

I would also ask if there is a possibility to set a more "dynamic" value to LetterSpace, because also with {\addfontfeature{LetterSpace=15em plus.1em minus.1em} I have some lines that go over the margin.

1

I guess the standard way would be to write a command. However, I do not see a difference of the last second and third paragraph in the PDF of the following MWE. All paragraphs have overfull \hboxes. I used XeLaTeX. The definition LetterSpace=15 corresponds to the fontspec manual and the other definition does not work in LuaTeX.

\documentclass{memoir}

\usepackage{fontspec}
\setmainfont{texgyrepagella-regular.otf}
\newcommand{\textls}[1]{{\addfontfeature{LetterSpace=15}#1}}

\usepackage{polyglossia}\setmainlanguage{english}
%\usepackage[english]{babel}

\begin{document}

honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus

\textls{honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus}

\addfontfeature{LetterSpace=15em plus.1em minus.1em}
honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus honorificabilitudinitatibus

\end{document}

EDIT I am glad that this solves at least one problem. Usually, I do not use Xe(La)TeX. Unfortunately, I cannot answer your good question on reducing the overfull boxes. I usually load microtype and either polyglossia or babel to reduce this problem by hyphenation and micro typography. Note that you would have to rename the command \textls when you load microtype (or use \renewcommand). Any more line overflows are then eliminated manually be rephrasing or manual line breaks at the end of the editing process. There should be plenty of questions here regarding this matter. For example on Text out of margins.

  • 1
    Thank you very much! It worked perfectly. Do you know if exists the possibility to use a sort of dynamic value to avoid margin crossing? – ALE Nov 19 '17 at 18:58
  • @Alessio: Unfortunately, I do not have a solution for this problem. Please see the edit of the answer. – CampanIgnis Nov 19 '17 at 19:09
  • Thank you for your reply, unfortunately I don't found a way to resolve the issue, I will edit the original question to reformulate my need – ALE Nov 19 '17 at 19:46
  • It may be very specific to my own setup (LuaLaTeX, fontspec, polyglossia, microtype, other things), but I have found that fontspec's LetterSpace' and microtype's \textls` do not play nicely together. So I use one or the other. Since LetterSpace is more versatile, I use it. Your results may differ. – user139954 Nov 19 '17 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.