-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnarrow.sty
42 lines (36 loc) · 1.52 KB
/
narrow.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{narrow}[2018/05/10]
\RequirePackage{kvoptions}
\RequirePackage{geometry}
\RequirePackage[strict]{changepage} % for adjustwidth environment
\DeclareStringOption[345pt]{width}
\DeclareStringOption[\textwidth]{fullwidth}
\ProcessLocalKeyvalOptions*
\newlength{\narrow@full}
\setlength{\narrow@full}{\narrow@fullwidth}
\geometry{textwidth=\narrow@width}
%% Define a fullwidth environment.
%%
%% I want to go from \textwidth to \narrow@full. adjustwidth adds to
%% margins, subtracting from text width, so I should adjust by
%% (\textwidth-\narrow@full)/2.
\newlength{\narrow@offset}
\setlength{\narrow@offset}
{\dimexpr(\textwidth-\narrow@full)/2\relax}
\newenvironment{fullwidth}
{\begin{adjustwidth}{\the\narrow@offset}{\the\narrow@offset}}
{\end{adjustwidth}}
%% Redefine figure* to use fullwidth.
%% TODO: should \centering be here?
%%
%% A hack, taken from https://stackoverflow.com/questions/1565988/making-a-small-modification-to-a-latex-environment
\renewenvironment{figure*}[1][\fps@figure]
{\edef\@tempa{\noexpand\@float{figure}[#1]}%
\@tempa\begin{fullwidth}\centering}
{\end{fullwidth}\end@float}
%% TODO: Unfortunately, adjustwidth adds vertical space when I use it in
%% figure*. I've tried various hacks to fix this[1][2] but none of them have
%% worked so far.
%
%% [1] https://tex.stackexchange.com/questions/163100/correcting-removing-adjustwidths-vertical-spacing
%% [2] https://tex.stackexchange.com/questions/289422/loosing-top-bottom-theorem-spacing-when-using-adjustwidth