4

I try to create a design similar to this one:

enter image description here

As you can see, the space between each letter is a bit longer than by default, which is great when typesetting something in capitals. I saw the following topics: Enlarging tracking (= letter spacing) but I was not able to adapt it with my document.

\documentclass{article}

\usepackage{sectsty}
\usepackage{xcolor}

% Create a new command, \addspaces, ta receive a string and format it as                                                 
% all uppecase with more spaces between letters.                                                                    
\def\theLetterSpace{0.5pt}
\def\theWordSpace{2\LocalLetterSpace}                      
\newlength\LocalLetterSpace
\newcommand\spaceout[2][\theLetterSpace]{%
\setlength\LocalLetterSpace{#1}\expandafter\spaceouthelpA#2 \relax\relax}                                             
\def\spaceouthelpA#1 #2\relax{%
    \spaceouthelpB#1\relax\relax                
}                                                                                                                       
\def\spaceouthelpB#1#2\relax{%
    #1%
    \ifx\relax#2\else                         
    \kern\LocalLetterSpace\spaceouthelpB#2\relax%               
    \fi
}     

\newcommand{\addspaces}[1]{
    \textsc{\large\spaceout[2pt]{#1}}
}

\sectionfont{\normalfont\LARGE\scshape\color{red}\raggedright}

\begin{document}
\section{†est}
\addspaces{Hello World}
\end{document}

Thank in advance for your help.

2
  • The options \sffamily and \scshape are bound to conflict unless you happen to employ a sans-serif font that provides small-caps. Is that the case for your document?
    – Mico
    Commented Feb 26, 2018 at 13:50
  • I don't get it. Why would you need a chapter for a mere four sentences? ;-) Commented Feb 26, 2018 at 16:14

2 Answers 2

6

You have to use \addfontfeatures, which however needs to declare fonts explicitly.

\documentclass{article}

\usepackage{fontspec}
\usepackage{sectsty}
\usepackage{xcolor}

\setmainfont{Latin Modern Roman}[
  SmallCapsFont={* Caps},
]

\newcommand{\spacedsc}{\scshape\addfontfeatures{LetterSpace=20}}

\sectionfont{\normalfont\LARGE\spacedsc\color{red!80!blue}\raggedright}

\begin{document}

\section{Special Relativity in Four Sentences}

\end{document}

enter image description here

0
4

Under pdfLaTeX and LuaLaTeX, you could load the letterspace package and add \lsstyle to the list of parameters set by \sectionfont.

enter image description here

\documentclass{article}
\usepackage{sectsty,xcolor}
\usepackage{letterspace}  % for "\lsstyle" macro

\sectionfont{\normalfont\LARGE\scshape\lsstyle\color{red}\raggedright}

\begin{document}
\section{Special Relativity in Four Sentences}
\end{document}
4
  • I'm sorry, I should have specified that I use XeLaTex. If that help, I don't need the sf font.
    – Nakrule
    Commented Feb 26, 2018 at 15:08
  • @Nakrule - Indeed, the fact that you use XeLaTeX is absolutely crucial here. Unfortunately, letterspacing is not available under XeLaTeX -- at least not with the letterspace package or its big brother, the microtype package. I'm not aware of any other packages that provide letterspacing under XeLaTeX.
    – Mico
    Commented Feb 26, 2018 at 15:16
  • In my document, I use a custom macro named addspaces{some text} to do add more spaces between letters and put everything in capitals. Before posting here, I tried to use it in my \sectionfont without any success, but maybe it is still possible to find a way with it ?
    – Nakrule
    Commented Feb 26, 2018 at 15:49
  • In your MWE you define \addspaces but you don't use it. Please show how you used it and say what the problem was. Might it have anything to do with the section title appearing in the ToC? Commented Feb 26, 2018 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .