I am discovering LuaLaTeX…
I want to produce pdf files from my tex
sources as small as possible.
If I compile the following code with LuaLaTeX
, the size of the generated pdf
is 9 kB.
\documentclass{article}
\usepackage{titlesec}
\usepackage{titling}
\usepackage{fontspec}
% Specify different font for section headings
\newfontfamily\headingfont[]{Gill Sans}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\titleformat*{\subsubsection}{\large\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}
\author{An author}
\title{The title of the article}
\date{\today}
\begin{document}
\maketitle
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}
If I compile the same code with LaTeX
but with a difference of font, the resulted files is 49 kB large. I guess the difference doesn't come from LaTeX
ou LuaLaTeX
but from the fonts. Something like : "my pdf
system knows better about the Gill Sans
font than the default LaTeX
fonts".
\documentclass{article}
\usepackage{titlesec}
\usepackage{titling}
%\usepackage{fontspec}
%% Specify different font for section headings
%\newfontfamily\headingfont[]{Gill Sans}
%\titleformat*{\section}{\LARGE\headingfont}
%\titleformat*{\subsection}{\Large\headingfont}
%\titleformat*{\subsubsection}{\large\headingfont}
%\renewcommand{\maketitlehooka}{\headingfont}
\author{An author}
\title{The title of the article}
\date{\today}
\begin{document}
\maketitle
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\end{document}
Can someone confirm this? Is there a rule to learn from this if one wants to produce very light files?
PS : If I use the same font, I get the same size !
PPS : Strangely, if I apply ghostscript
on the pdf
file generated by LuaLaTex
, the size gets bigger (from 9 kB to 12 kB !). The file generated by LaTex
: from 49 kB to 13 kB.
PPPS : In my naive way of understanding things, using a custom font, such as Gill Sans
would normally produce a bigger file than if using the standard font.
Best Answer
I'm using Linux Libertine heavily and each PDF, made with pdfLaTeX, had a size of some hundred KB. pdfTeX (as far as I know called by pdfLaTeX) embeds the fonts in the PDF, but it does not compress them.
There was a wonderful tool called
pdfsizeopt
, written by Peter Szabo and published at Google Code. It compressed the fonts inside the PDF heavily; mine usually by factor 10!Well, sadly enough, the page http://pdfsizeopt.googlecode.com/ was taken down for alleged copyright issues. New home is here:Â https://github.com/pts/pdfsizeopt (Thank you, giordano). There you will find a paper Szabo published about the compression going down to a very detailed level.
In short: The difference between LuaLaTeX and PDFLaTeX seems to be the way of embedding the fonts, namely the used compression.
So as a result to those batshit crazy laws you'd better not publish you code with googlecode.