0

I have a document with a large number of figures and not much text (about six lines per page). Using the figure environment isn't an option since I can't decide the position of each image. Now I'm just using \includegraphics{} and

\begin{center}
\begin{tikzpicture}
...
\end{tikzpicture}
\end{center}

so I choose exactly where each image should be. Is there a way I can number these images? I might add a theorem-like environment inside each tikzpicture, but it doesn't work for includegraphics. Is there a better solution?

user5402
  • 346

1 Answers1

1

If you REALLY want to pack them tightly, you can use something like this:

\documentclass{article} 
\usepackage{tikz}
\usepackage{varwidth}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{showframe}

\begin{document}
\begin{figure}[tp]
\sbox0{\rule{4cm}{2cm}}% normally use a tikzpicture of unknown size
\sbox1{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{First}
\end{minipage}}%
%
\sbox0{\rule{4cm}{4cm}}%
\sbox2{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Second}
\end{minipage}}%
%
\sbox0{\rule{3cm}{2cm}}%
\sbox3{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Third}
\end{minipage}}%
%
\sbox0{\rule{3cm}{4cm}}%
\sbox4{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Fourth}
\end{minipage}}%
%
\sbox0{\rule{\textwidth}{2cm}}
\sbox5{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Fifth}
\end{minipage}}%
%
\sbox0{\rule{4cm}{2cm}}%
\sbox6{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Sixth}
\end{minipage}}%
%
\centering
\begin{tikzpicture}[inner sep=0pt, outer sep=0.5\columnsep]
\begin{scope}[local bounding box=S1]
  \node (A) {\usebox1};
  \node[below right] (B) at (A.north east) {\usebox2};
  \node[below right] (C) at (B.north east) {\usebox3};
  \node[below right] (D) at (C.south west) {\usebox4};
  \node[below right] (F) at (A.south west) {\usebox6};
\end{scope}
  \node[below] (E) at (S1.south) {\usebox5};
\end{tikzpicture}
\end{figure}
\lipsum[1-6]
\end{document}

demo


I found a simpler and more compact alternative. Here the saveboxes only serve to make shuffling them around easier, and rearrange the caption order.

\documentclass{article} 
\usepackage{tikz}
\usepackage{varwidth}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{showframe}

\begin{document}
\begin{figure}[tp]
\sbox0{\rule{4cm}{2cm}}% normally use a tikzpicture of unknown size
\sbox1{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{First}
\end{minipage}}%
%
\sbox0{\rule{4cm}{4cm}}%
\sbox2{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Second}
\end{minipage}}%
%
\sbox0{\rule{3cm}{2cm}}%
\sbox3{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Third}
\end{minipage}}%
%
\sbox0{\rule{3cm}{4cm}}%
\sbox4{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Fourth}
\end{minipage}}%
%
\sbox0{\rule{\textwidth}{2cm}}
\sbox5{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Fifth}
\end{minipage}}%
%
\sbox0{\rule{4cm}{2cm}}%
\sbox6{\begin{minipage}{\wd0}
  \usebox0
  \captionof{figure}{Sixth}
\end{minipage}}%
%
\centering
\raisebox{-\height}{\usebox1}\hfill
\raisebox{-\height}{\usebox2}\hfill
\raisebox{-\height}{\usebox4}

\raisebox{\dimexpr 0.5\depth-0.5\height}{\usebox3}\hfil
\raisebox{\dimexpr 0.5\depth-0.5\height}{\usebox6};

\usebox5
\end{figure}
\lipsum[1-6]
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120