# Make negative spacing between letters and make them darker on the overlapping parts

I want to make number of the chapter to be as big as the paper. This is what I have achieved so far.

What I want is to make negative spaces between letters, so they overlap and the overlapping part is darker than the numbers themselves. Or to make the second number darker than the first one, but still overlap. I have absolutely no idea how to automate that.

I also keep titlesec in my code, because I am not aware of anything that could go wrong (or right), when I implement the solution.

Here is my MWE.

\documentclass[12pt,twoside,draft]{scrbook}

\usepackage{geometry}
\geometry{
paperwidth=11.7in,
paperheight=8.27in,
top=1in,
bottom=1in,
outer=1.5in,
inner=0.7in,
voffset=0in,
marginparwidth=0.5in,
marginparsep=0.2in,
footskip=0em,
nofoot,
}

\usepackage{mathtools}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{anyfontsize}
\usepackage{titlesec}
\usepackage[english]{babel}

\titleformat{\chapter}[display]
{\normalfont\bfseries\color{gray!100!white!50}\fontsize{\paperheight}{\paperheight}\selectfont}%
{\resizebox{!}{\paperheight+1in}{\thechapter}}%
{-\paperheight}%
{\color{black}\raggedright\Huge}

\titlespacing{\chapter}{0in}{-1.5in}{40pt}

\begin{document}

\setcounter{chapter}{20}
\chapter{Twenty One}

\lipsum[1]

\end{document}


I made several changes. I made the color for each digit \color{gray!100!white!\intens where \intens is changed for each digit, from 50 to 75 and then (if needed) 100.

Also, I present the chapter, instead of \thechapter, as \edef\tmp{\thechapter}\expandafter\squeeze\tmp\relax, where \squeeze does a negative kern after each digit and a change of color.

\documentclass[12pt,twoside,draft]{scrbook}

\usepackage{geometry}
\geometry{
paperwidth=11.7in,
paperheight=8.27in,
top=1in,
bottom=1in,
outer=1.5in,
inner=0.7in,
voffset=0in,
marginparwidth=0.5in,
marginparsep=0.2in,
footskip=0em,
nofoot,
}

\usepackage{mathtools}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{anyfontsize}
\usepackage{fontspec}
\newfontfamily\chapterfont[LetterSpace=-12]{Latin Modern Roman}
\usepackage{titlesec}
\usepackage[english]{babel}

\titleformat{\chapter}[display]
{\gdef\intens{50}\normalfont\bfseries\color{gray!100!white!\intens}\fontsize{\paperheight}{\paperheight}\selectfont}%
{\resizebox{!}{\paperheight+1in}{%
\chapterfont\edef\tmp{\thechapter}\expandafter\squeeze\tmp\relax}}%
{-\paperheight}%
{\color{black}\raggedright\Huge}

\titlespacing{\chapter}{0in}{-1.5in}{40pt}
\def\squeeze#1#2\relax{#1\ifx\relax#2\relax\ \else%
\xdef\intens{\the\numexpr\intens+25\relax}%
\kern-180pt\color{gray!100!white!\intens}\squeeze#2\relax\fi}
\begin{document}

\setcounter{chapter}{20}
\chapter{Twenty One}

\lipsum[1]

\setcounter{chapter}{101}
\chapter{Century Plus Two}

\lipsum[1]

\end{document}


• This looks very good, but when I do \newfontfamily\chapterfont[LetterSpace=-12]{Calibri}, a strange vertical line appears on the right. Why does this happen? – Michael Fraiman Jun 7 '17 at 5:32
• @MichaelFraiman I do not know why it does that, however, I EDITED and fixed it by having \squeeze set an extra space to the big chapter number when complete. – Steven B. Segletes Jun 7 '17 at 9:52
• @StevenB.Segletes you you use tikz+opacity to get the overlaps colored? – daleif Jun 7 '17 at 9:55
• @StevenB.Segletes I've added an example below, though have not integrated it with titlesec as I'm unfamiliar with that package. – daleif Jun 7 '17 at 11:38
• @MichaelFraiman Typically, you would use \chapter{} instead of \chapter{Twenty One}. If you still needed the name in the table of contents, but not on this page, you would say \chapter[Twenty One]{} – Steven B. Segletes Jun 7 '17 at 12:13

The negative kerning is quite easy to do with fontspec and XeLaTeX or LuaLaTeX. I've used the LetterSpace font feature for the font used for the number. Giving it a negative value decreases the inter-letter spacing. I've given it a value of -12 as an example, which doesn't actually overlap them but gives you an idea of what you can do. (I tried larger numbers but nothing looked very pleasing to my eye.) This is not a scale number but an "normalized additive factor defined as a percentage of the font size. For a 10 pt font 1.0 will add 0.1pt between each letter." (fontspec docs, p.33).

This doesn't solve the "darker when overlapping" issue, though. For that you might need to treat the digits individually with TikZ or something.

\documentclass[12pt,twoside,draft]{scrbook}

\usepackage{geometry}
\geometry{
paperwidth=11.7in,
paperheight=8.27in,
top=1in,
bottom=1in,
outer=1.5in,
inner=0.7in,
voffset=0in,
marginparwidth=0.5in,
marginparsep=0.2in,
footskip=0em,
nofoot,
}

\usepackage{mathtools}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{anyfontsize}
\usepackage{fontspec}
\newfontfamily\chapterfont[LetterSpace=-12]{Latin Modern Roman}
\usepackage{titlesec}
\usepackage[english]{babel}

\titleformat{\chapter}[display]
{\normalfont\bfseries\color{gray!100!white!50}\fontsize{\paperheight}{\paperheight}\selectfont}%
{\resizebox{!}{\paperheight+1in}{\chapterfont\thechapter}}%
{-\paperheight}%
{\color{black}\raggedright\Huge}

\titlespacing{\chapter}{0in}{-1.5in}{40pt}

\begin{document}

\setcounter{chapter}{20}
\chapter{Twenty One}

\lipsum[1]

\end{document}


Example with full overlap (value of -35):

• But it is not what I want really. The idea is to make one number look like it is behind another, by darkening part that overlaps. – Michael Fraiman Jun 6 '17 at 21:40
• Ok I can delete it. I think what you want is a really tough problem. – Alan Munn Jun 6 '17 at 21:41
• yeah, that's why I asked it here) – Michael Fraiman Jun 6 '17 at 21:42
• No need to delete it, though. It might still be useful to someone. – Sverre Jun 6 '17 at 22:03
• @AlanMunn That's strange. This is what I get with \newfontfamily\chapterfont[LetterSpace=-35,Opacity=0.5]{Latin Modern Roman}: http://imgur.com/a/8anWE (TL 2016, though) – Robert Jun 7 '17 at 22:48

This is not really an answer to the original question, just a note from a discussion with Steven. Here is a crude method of squeezing and coloring the overlap using tikz opacity. Stevens sqeeze slitter code is stil used.

\documentclass[a4paper]{standalone}
\usepackage[T1]{fontenc}
\usepackage{fix-cm}
\usepackage{tikz,etoolbox,xcolor}
\usetikzlibrary{calc}
\def\myList{}
\def\intens{50}
\def\pullback{10mm}
\def\squeeze#1#2\relax{
\ifx\relax#2\relax\else%
\xdef\intens{\the\numexpr\intens+25\relax}%
\squeeze#2\relax%
\fi}
\newcommand\Handler[1]{
\begingroup
\def\Splitter##1##2\relax{\gdef\VAL{##1}\gdef\INT{##2}}
\expandafter\Splitter#1\relax
\node[gray!100!white!\INT,opacity=0.5]
at ($(0,0)+(\adjustment,0)$) {\fontsize{10cm}{10cm}\selectfont\VAL};
\endgroup
}
\newcommand\DoSqeezed[1]{%
\def\myList{}%
\edef\tmp{#1}%
\expandafter\squeeze\tmp\relax%
\tikz\forlistloop\Handler\myList;
}
\begin{document}
\DoSqeezed{21}
\DoSqeezed{213}
\end{document}


This could probably be placed in the background either through some feature in titlesec (I don;t use it so unfamilliar) or by using a standard

\begin{tikzpicture}[remember picture,overlay]
...
\end{tikzpicture}


instead of the \tikz ... ; wrapper.

Slightly adjusted version, which should also work with old style numerals. Also switched to memoir to test a few things that are not easy to test in the standalone class

\documentclass[a4paper]{memoir}
\setlrmarginsandblock{1cm}*1
\checkandfixthelayout
\pagestyle{empty}
\usepackage[T1]{fontenc}
\usepackage{fix-cm}
\usepackage{tikz,etoolbox,xcolor}
\usetikzlibrary{calc}
\newcommand\myList{}
\newcommand\intens{50}
\newcommand\pullback{10mm}
\def\squeeze#1#2\relax{
\ifx\relax#2\relax\else%
\xdef\intens{\the\numexpr\intens+25\relax}%
\squeeze#2\relax%
\fi}
\newcommand\Handler[1]{
\begingroup
\def\Splitter##1##2\relax{\gdef\VAL{##1}\gdef\INT{##2}}
\expandafter\Splitter#1\relax
\node[anchor=mid west,gray!100!white!\INT,opacity=0.5]
at ($(0,0)+(\adjustment,0)$) {\fontsize{10cm}{10cm}\selectfont\VAL};
\endgroup
}
\newcommand\DoSqeezed[1]{%
\renewcommand\myList{}%
\edef\myTemp{#1}%
\expandafter\squeeze\myTemp\relax%
\tikz
%[remember picture,overlay]
\forlistloop\Handler\myList;
}
\begin{document}
%\newcounter{chapter}
\setcounter{chapter}{678}
\DoSqeezed{\thechapter}
\DoSqeezed{213}
\end{document}

• Wow, this is what I wanted from the beginning. I guess working this out will give a mignificent result. – Michael Fraiman Jun 7 '17 at 11:59
• Would be safer to avoid \def and I believe that fix-cm is no longer needed. (+1) for the core code, though. – cfr Jun 7 '17 at 12:52
• @cfr on my TL16 frozen fix-cm is needed in order to scale the fonts that high. For some of the code the defs can be replaced but for the delimited stuff we probably cannot. – daleif Jun 7 '17 at 13:41
• I'm obviously wrong about fix-cm, then. I must be confusing it with something else. – cfr Jun 7 '17 at 22:27

You can use PDF primitive commands for overlapping. Especially the /Multiply method in Graphic State in order to create the overlapped area darker. You don't need to use Tikz.

 \def\thechapnum{12}

\pdfpageresources{/ExtGState << /mul << /Type /ExtGState /BM /Multiply >> >>}

\def\insertkerns#1{\ifx\end#1\else #1\kern-.3em \expandafter\insertkerns\fi}

\leavevmode{\bf\pdfsave\pdfliteral{/mul gs 0.5 g 80 0 0 80 -100 -500 cm}%
\rlap{\expandafter\insertkerns\thechapnum\end}\pdfrestore}

rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire
rryuir weeeyuirw fuow ediwe yiriw rfirer rf re ipr ire

\bye


Note that the parameters of cm operator are used for scaling and shifting the result into proper place in the page.