6

I have a question, whether there is some possibility to adjust kerning around some specific symbols without caring what symbols will be written next. Also, could I possibly adjust kerning only for specific font shapes?

Specifically, I need to use the Alegreya font, but I've noticed that some symbols (e.g., double quote marks, f letter) leave very little space after themselves.

Please, look at the picture and its source code below: italic shape looks worse than roman, I almost can't tell if there is some space between some words or not. Only inserting double space makes the difference.

Alegreya font

\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}
\setmainfont[
  Numbers=OldStyle,
  Extension = .ttf,
  UprightFont= *-Regular,
  BoldFont=*-Bold,
  ItalicFont=*-Italic,
  BoldItalicFont=*-BoldItalic,
  SmallCapsFont=*SC-Regular,
  ItalicFeatures={SmallCapsFont=*SC-Italic},
  ]{Alegreya}

\begin{document}
    Types of $^\text{6}_\text{4}$ chords.\par
    \textit{Types of $^\text{6}_\text{4}$ chords.}\par
    ``good'' harmonic progressions of motion,'' most cases are\par
    \textit{``good'' harmonic progressions of motion,'' most cases are}\par
    \textit{``good' harmonic progressions of motion,' most cases are}\par
    \textit{``good''\/ harmonic progressions of motion,''\/ most cases are}\par
    \textit{``good''~harmonic progressions of motion,''~most cases are}\par
    \textit{``good''~~harmonic progressions of motion,''~~most cases are}\par
    \textbf{``good'' harmonic progressions of motion,'' most cases are}\par
    \textbf{\textit{ ``good'' harmonic progressions of motion,'' most cases are}}\par
    transformed himself transformed himself\par
    \textit{transformed himself transformed himself}    
\end{document}

I've seen some suggestions to use microtype package (e.g., non-invasive kerning/spacing modification: what options are there?), but I've noticed, that microtype and word breaking does not work so great together. Please see the image and its source code below (tested with TeX Live 2015 LuaTeX): notice the word-break hyphen alignment with and without the microtype package.

Microtype and word breaking

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage{fontspec}
\setmainfont[
  Numbers=OldStyle,
  Extension = .ttf,
  UprightFont= *-Regular,
  BoldFont=*-Bold,
  ItalicFont=*-Italic,
  BoldItalicFont=*-BoldItalic,
  SmallCapsFont=*SC-Regular,
  ItalicFeatures={SmallCapsFont=*SC-Italic}
  ]{Alegreya}

% code to draw two column margin is taken from:
% https://tex.stackexchange.com/questions/271285/show-frame-margin-in-two-column-layout/271294 
\usepackage{showframe}
\newlength\Fcolumnseprule
\setlength\Fcolumnseprule{0.4pt}
\makeatletter
\def\@outputdblcol{%
  \if@firstcolumn
    \global \@firstcolumnfalse
    \global \setbox\@leftcolumn \box\@outputbox
  \else
    \global \@firstcolumntrue
    \setbox\@outputbox \vbox {%
                         \hb@xt@\textwidth {%
                           \hb@xt@\columnwidth {%
                             \box\@leftcolumn \hss}%
                           \vrule \@width\Fcolumnseprule\hfil
                                {\normalcolor\vrule \@width\columnseprule}%original:
                                                %\normalcolor\vrule \@width\columnseprule
                           \hfil\vrule \@width\Fcolumnseprule
                           \hb@xt@\columnwidth {%
                             \box\@outputbox \hss}%
                                             }%
                              }%
    \@combinedblfloats
    \@outputpage
    \begingroup
      \@dblfloatplacement
      \@startdblcolumn
      \@whilesw\if@fcolmade \fi
        {\@outputpage
         \@startdblcolumn}%
    \endgroup
  \fi
}
\makeatother

\begin{document}
\section{Without microtype}
\microtypesetup{activate=false}
\lipsum[3]
\section{With microtype}
\microtypesetup{activate=true}
\lipsum[6]
\end{document}

I would be very grateful for some suggestions.

EDIT: Henri Menke showed me, that setting protrusion=False, helps to fix hyphen alignment using microtype package. So I tried to fix my initial problem using \SetExtraKerning only to find out that kerning option is not available for LuaTeX.

  • 4
    Welcome to TeX.SX! Side-comment: I don't get the comparison with and without microtype since you don't use the same \lipsum[x] (i.e. didn't you want to use \lipsum[3] in both paragraphs?). Anyway, the fact that hyphen are a bit in the margin is what you want to achieve with microtype. Without showframe, each line should looks better balanced. – ebosi May 25 '16 at 08:43
  • 5
    microtype enables margin kerning, which is why the hyphen is kerned into the margin. You turn it off with protrusion=false. Word breaking will always be bad for Lorem Ipsum in LaTeX, because there are no hyphenation patterns for ancient Latin built in. The default patterns are for English, so your text is hyphenated as if it was in English. – Henri Menke May 25 '16 at 08:51
  • @ebo, I don't want to use \lipsum[3] in both paragraphs, because, I want to show as many word breaks as possible, to show my case. With microtype package the same text lies differently, mostly without word breaks at all. – liolliokas May 25 '16 at 10:53
  • @HenriMenke setting protrusion=false helps, but only now I noticed and if I understand correctly microtype kerning option doesn't work with LuaTeX engine, and this package can't help me at all. – liolliokas May 25 '16 at 10:54
  • 3
    @liolliokas BTW: If it is mainly interword spacing that is too tight for you, you might want to consider the WordSpace option of fontspec which multiplies the interword space with the given factor, e.g. \setmainfont[WordSpace=1.5]{Alegreya} for one-and-a-half word space. – Henri Menke May 25 '16 at 11:33
  • Off-topic: commands such as \rm, \bf etc. ought not be used with the LaTeX format having been deprecated 20+ years ago. – cfr May 25 '16 at 11:45
  • 1
    @liolliokas Yeah but a comparison doesn't really work well if you don't use all the same factors except the one which the comparison is about. – Alenanno May 25 '16 at 11:53
  • It is strange to use maths super and subscripts which are not attached to anything, so it isn't surprising that the spacing is problematic there. – cfr May 25 '16 at 11:53
  • Also, it means the numbers shown are from Computer Modern. – cfr May 25 '16 at 12:01
  • @cfr, I fixed my sample according to Your remarks. Originally, numbers are used also in Alegreya font and all situations provided in sample are real and need to be typeset as is shown only with more visible spaces where they should be. – liolliokas May 25 '16 at 12:43
  • @HenriMenke WordSpace=1.5 looks OK for small text, but for the whole two-column paper it stretches spaces between words where it shouldn't. – liolliokas May 25 '16 at 12:54
  • But you shouldn't have a math superscript and subscript floating like that in the middle of text. That's my point. – cfr May 25 '16 at 13:32
  • 1
    @liolliokas Then use something smaller than 1.5. These questions are also related https://tex.stackexchange.com/questions/10455/is-there-a-way-to-adjust-kerning-for-a-specific-character-combination/10473 https://tex.stackexchange.com/questions/52929/how-to-fix-kerning-of-comma-colon-after-quotes/53594 – Henri Menke May 28 '16 at 09:52
  • @HenriMenke, I actually have tried to use smaller values, but not all spaces need to be corrected, so it looks a bit awkward.. Thanks for the links. I'm trying to understand how I could increase space after certain symbols if they are at the end of the word. Perhaps I could use Lua code or load FeatureFile for fontspec package. – liolliokas May 30 '16 at 06:50
  • 1
    @liolliokas Support for feature files has been dropped as of version 2.7 of luaotfload: https://github.com/lualatex/luaotfload/issues/347 – Henri Menke May 30 '16 at 07:04
  • @HenriMenke, thanks, You've saved me some time :) – liolliokas May 30 '16 at 10:49
  • Can I use the microtype package with LuaTeX to get the kerning feature? – skan Nov 19 '16 at 16:58

0 Answers0