Skip to content

Instantly share code, notes, and snippets.

@yig
Last active December 5, 2024 15:39
Show Gist options
  • Save yig/81b4c993ea13252edc81 to your computer and use it in GitHub Desktop.
Save yig/81b4c993ea13252edc81 to your computer and use it in GitHub Desktop.
Latex space saving tricks
%% Make everything look better.
%% http://tex.stackexchange.com/questions/553/what-packages-do-people-load-by-default-in-latex
%% http://www.howtotex.com/packages/9-essential-latex-packages-everyone-should-use/
\usepackage{microtype}
%% Shrink space around figures.
%% This beats manually adding negative \vspace commands everywhere.
%\setlength{\textfloatsep}{0pt}
%\setlength{\textfloatsep}{20pt plus 2pt minus 4pt}
%\setlength{\textfloatsep}{10pt plus 2pt minus 4pt}
%\setlength{\textfloatsep}{10pt plus 1pt minus 2pt}
%\setlength{\dbltextfloatsep}{3pt}
%\setlength{\intextsep}{5pt}
%\setlength{\abovecaptionskip}{5pt}
%\setlength{\belowcaptionskip}{3pt}
%\setlength{\parskip}{4pt}
%% around equations
%\setlength{\abovedisplayskip}{3pt}
%\setlength{\belowdisplayskip}{3pt}
%\setlength\abovedisplayshortskip{3pt}
%\setlength\belowdisplayshortskip{3pt}
%% The wrapfigure environment is also a good way to use less space for a small figure.
%% It is finicky.
%% See: http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Wrapping_text_around_figures
%% Shrink space around enumerate and itemize
%% From: http://tex.stackexchange.com/questions/10684/vertical-space-in-lists
%\usepackage{enumitem}
%% Set it globally:
% \setlist{nosep} % or \setlist{noitemsep} to leave space around whole list
% \setlist{itemsep=1pt, topsep=3pt}
%% Or locally:
% \begin{enumerate}[itemsep=1pt, topsep=12pt, partopsep=0pt]
%% Less space around titles.
%% From: http://tex.stackexchange.com/questions/4999/change-whitespace-above-and-below-a-section-heading
%\usepackage[medium,compact]{titlesec}
%% or
%\usepackage{titlesec}
%\titlespacing*{\section}{0pt}{*1}{*1}
%% Shrink the \paragraph command.
%\renewcommand{\paragraph}[1]{\noindent {\bf #1}}
%% Allow Latex to use a smaller minimum spacing between lines.
%\renewcommand{\baselinestretch}{0.97}
%\renewcommand{\baselinestretch}{0.982}
%% Shrink space between lines. You probably want to prefer baselinestretch in general.
%% From: http://tex.stackexchange.com/questions/23824/6-lines-in-one-inch
%% 6 lines in one inch with an 11pt font:
%\linespread{0.901}
%\linespread{0.909}
%\linespread{1}
%% Shrink the spacing between lines in just the bibliography. This is good.
% \usepackage{setspace}
%% Then wrap the bibliography in a \begin{spacing}. You can wrap any section like this.
% \begin{spacing}{0.9}
% \bibliographystyle{...}
% \bibliography{references}
% \end{spacing}
@xiaohk
Copy link

xiaohk commented Sep 13, 2021

Super helpful list!

I also like to use \looseness=-1 at the end of a paragraph to deal with widow words.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment