/
figalign.tex
326 lines (302 loc) · 10 KB
/
figalign.tex
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
\documentclass[12pt,english]{article}
% Basic packages
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{blindtext}
\usepackage{listings}
% Margins
\usepackage{geometry}
\geometry{
a3paper,
noheadfoot=true,
left=1.0in,
right=1.0in,
top=1.0in,
bottom=1.0in,
}
% url package
\usepackage[colorlinks=true,
linkcolor=blue,
urlcolor=blue,
anchorcolor = blue,
citecolor=gray]{hyperref}
% Specific Packages
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
\captionsetup[figure]{labelfont={bf},name={Fig.},labelsep=period}
% Titling and Author
\title{Latex Examples with the \href{https://ctan.org/pkg/subcaption?lang=en}{subcaption} and \href{https://ctan.org/pkg/caption?lang=en}{caption} packages, Figure Vertical and Horizontal Alignments with Subfigures}
\author{\href{https://fanwangecon.github.io/}{Fan Wang}\thanks{https://fanwangecon.github.io, repository: \href{https://fanwangecon.github.io/Tex4Econ/}{Tex4Econ}}}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\clearpage
\section{Center alignment of a single figure}
Figures \ref{fig:single_a} and \ref{fig:single_b} have the following features:
\begin{itemize}
\item Separate widths for caption and image.
\end{itemize}
\lstset{%
basicstyle=\footnotesize\ttfamily,
breaklines=true,
language=[LaTeX]{TeX}
}
\begin{lstlisting}[frame=single]
% Included Package
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
\captionsetup[figure]{labelfont={bf},name={Fig.},labelsep=period}
% Code
\begin{figure}[H]
\centering
% 0.3 inside includegraphics control figure proportional to textwidth
\includegraphics[width=0.3\textwidth]{example-image-a}
% Note 0.7 inside captionsetup control caption width
\captionsetup{width=0.7\textwidth}
\caption{\blindtext}
\label{fig:single_a}
\end{figure}
\par\medskip
\begin{figure}[H]
\centering
% 0.3 inside includegraphics control figure proportional to raw image width
\includegraphics[scale=0.3]{example-image-a}
% Note 0.9 inside captionsetup control caption width
\captionsetup{width=0.7\textwidth}
\caption{\blindtext}
\label{fig:single_b}
\end{figure}
\end{lstlisting}
\par\medskip
\begin{figure}[H]
\centering
% 0.3 inside includegraphics control figure proportional to textwidth
\includegraphics[width=0.3\textwidth]{example-image-a}
% Note 0.7 inside captionsetup control caption width
\captionsetup{width=0.7\textwidth}
\caption{\blindtext}
\label{fig:single_a}
\end{figure}
\par\medskip
\begin{figure}[H]
\centering
% 0.3 inside includegraphics control figure proportional to raw image width
\includegraphics[scale=0.3]{example-image-a}
% Note 0.9 inside captionsetup control caption width
\captionsetup{width=0.7\textwidth}
\caption{\blindtext}
\label{fig:single_b}
\end{figure}
\pagebreak
\section{Vertical center align with subfigures}
Figure \ref{fig:vert} has the following features:
\begin{itemize}
\item An overall caption with width control
\item Below figure notes with width control
\item subfigure vertically center aligned
\end{itemize}
\lstset{%
basicstyle=\footnotesize\ttfamily,
breaklines=true,
language=[LaTeX]{TeX}
}
\begin{lstlisting}[frame=single]
% Included Package
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
\captionsetup[figure]{labelfont={bf},name={Fig.},labelsep=period}
% Code
\begin{figure}[H]
\centering
\captionsetup{width=.85\textwidth}
\caption{\blindtext}
\label{fig:vert}
\begin{subfigure}[t]{0.45\textwidth}
% Sub-caption
\centering
\caption{Contours of indifference curves at given estimates}
\includegraphics[width=\linewidth]{example-image-a}
\end{subfigure}
\par\bigskip % this line generates two rows
\begin{subfigure}[t]{0.35\textwidth}
% Sub-caption
\centering
\caption{Vary $\mu_{R}$}
\includegraphics[width=0.5\linewidth]{example-image-b}
\end{subfigure}
\par\bigskip
\parbox[t]{0.90\textwidth}{\footnotesize \emph{Note:} \blindtext}\\
\end{figure}
\end{lstlisting}
\par\medskip
\begin{figure}[H]
\centering
\captionsetup{width=.85\textwidth}
\caption{\blindtext}
\label{fig:vert}
\begin{subfigure}[t]{0.45\textwidth}
% Sub-caption
\centering
\caption{Contours of indifference curves at given estimates}
\includegraphics[width=\linewidth]{example-image-a}
\end{subfigure}
\par\bigskip % this line generates two rows
\begin{subfigure}[t]{0.35\textwidth}
% Sub-caption
\centering
\caption{Vary $\mu_{R}$}
\includegraphics[width=0.5\linewidth]{example-image-b}
\end{subfigure}
\par\bigskip
\parbox[t]{0.90\textwidth}{\footnotesize \emph{Note:} \blindtext}\\
\end{figure}
\pagebreak
\section{Horizontal center align with subfigures}
Figure \ref{fig:horz} has the following features:
\begin{itemize}
\item Two subfigures on the same line, possibly exceeding pagewidth
\item Long wrapped captions
\end{itemize}
\lstset{%
basicstyle=\footnotesize\ttfamily,
breaklines=true,
language=[LaTeX]{TeX}
}
\begin{lstlisting}[frame=single]
% Included Package
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
% Code
\begin{figure}[H]
\centering
\begin{subfigure}[t]{.51\textwidth}
\centering
% included graphics appear smaller than full
\includegraphics[width=0.48\linewidth]{example-image-b}
\caption{\blindtext}
\end{subfigure}~
% tilde makes subfigures appear on the same row even if > 1.0 of textwidth
\begin{subfigure}[t]{0.48\textwidth}
\centering
% linewidth so that included graphics fills subfigure
\includegraphics[width=\linewidth]{example-image-a}
\caption{Vary $\mu_{R}$}
\end{subfigure}
\caption{\blindtext}
\label{fig:horz}
\end{figure}
\end{lstlisting}
\par\medskip
\begin{figure}[H]
\centering
\begin{subfigure}[t]{.51\textwidth}
\centering
% included graphics appear smaller than full
\includegraphics[width=0.48\linewidth]{example-image-b}
\caption{\blindtext}
\end{subfigure}~
% tilde makes subfigures appear on the same row even if > 1.0 of textwidth
\begin{subfigure}[t]{0.48\textwidth}
\centering
% linewidth so that included graphics fills subfigure
\includegraphics[width=\linewidth]{example-image-a}
\caption{Vary $\mu_{R}$}
\end{subfigure}
\caption{\blindtext}
\label{fig:horz}
\end{figure}
\pagebreak
\section{Horizontal and vertical center align with subfigures}
Figure \ref{fig:verthorz} has the following features:
\begin{itemize}
\item Center align multiple rows of figures
\item Caption width and wrapping same as subfigure width
\end{itemize}
\lstset{%
basicstyle=\footnotesize\ttfamily,
breaklines=true,
language=[LaTeX]{TeX}
}
\begin{lstlisting}[frame=single]
% Included Package
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
% Code
\newcommand{\subFigWidth}{0.27}
\newcommand{\subFigGraphWidth}{0.90}
\newcommand{\maincapwidth}{0.80}
\begin{figure}[H]
\centering
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-a}
\captionsetup{width=\subFigGraphWidth\textwidth}
\caption{$\alpha$}
\end{subfigure}~
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-b}
\captionsetup{width=\subFigGraphWidth\textwidth}
\caption{Primary school consolidation--the closure of small community schools or their mergers into larger.}
\end{subfigure}
\par\medskip
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-a}
\captionsetup{width=\subFigGraphWidth\textwidth}
\caption{We consider heterogeneous treatment effects across groups defined at the intersections of minority status.}
\end{subfigure}~
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\captionsetup{width=\subFigGraphWidth\textwidth}
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-b}
\caption{Compared to villages with schools, villages whose schools had closed reported that the schools students}
\end{subfigure}
\captionsetup{width=\maincapwidth\textwidth}
\caption{Results show that intersections of minority status, gender, and community characteristics can delineate significant heterogeneities in policy impacts.}
\label{fig:verthorz}
\end{figure}
\end{lstlisting}
\par\medskip
\newcommand{\subFigWidth}{0.27}
\newcommand{\subFigGraphWidth}{0.90}
\newcommand{\maincapwidth}{0.80}
\begin{figure}[H]
\centering
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-a}
\captionsetup{width=\subFigGraphWidth\textwidth}
\caption{$\alpha$}
\end{subfigure}~
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-b}
\captionsetup{width=\subFigGraphWidth\textwidth}
\caption{Primary school consolidation--the closure of small community schools or their mergers into larger.}
\end{subfigure}
\par\medskip
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-a}
\captionsetup{width=\subFigGraphWidth\textwidth}
\caption{We consider heterogeneous treatment effects across groups defined at the intersections of minority status.}
\end{subfigure}~
\begin{subfigure}[t]{\subFigWidth\textwidth}
\centering
\captionsetup{width=\subFigGraphWidth\textwidth}
\includegraphics[width=\subFigGraphWidth\linewidth]{example-image-b}
\caption{Compared to villages with schools, villages whose schools had closed reported that the schools students}
\end{subfigure}
\captionsetup{width=\maincapwidth\textwidth}
\caption{Results show that intersections of minority status, gender, and community characteristics can delineate significant heterogeneities in policy impacts.}
\label{fig:verthorz}
\end{figure}
\pagebreak
\end{document}