# Is there a LaTeX or LuaTeX equivalent to the layers in ConTeXt or exact vertical positioning?

I'm creating a document with complex layout of tables and figures, some need to be properly aligned vertically, horizontally or placed at some specific position. I'm using minipages and I was told to use tabular or subfigures.

Example with minipages:

\documentclass{article}
\usepackage{mwe} % new package from Martin scharrer
\usepackage{caption}
\begin{document}

\begin{figure}
\centering
\begin{minipage}[c]{\textwidth}
\centering
\includegraphics[width=3.0in]{example-image-a}
\caption{Caption for image}
\label{fig:sample_figure}
\end{minipage}
\end{figure}

\noindent
\begin{minipage}[c]{\textwidth}
\centering
\includegraphics[width=3.0in]{example-image-a}
\captionof{figure}{Caption for image}
\label{fig:sample_figure}
\end{minipage}

\end{document}


But you cannot specify the vertical allignement nor the exact vertical dimensions of the minipages nor more complex structures. If the figures don't have the same vertical dimensions it becomes a nightmare. Yo can try to align it on top or bottom ot center but not much more.

Example with tabular:

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{table}[ht]
\caption{table caption...}
\centering
\begin{tabular}{cc}
\includegraphics[width=45mm]{w.png} &\includegraphics[width=45mm]{x.png}\\
\newline
\includegraphics[width=45mm]{y.png}&\includegraphics[width=45mm]{z.png}\\
\end{tabular}
\end{table}
\end{document}


Example with subfigures:

\documentclass{article}
\usepackage{mwe} % For dummy images
\usepackage{subcaption}
\begin{document}
{\centering
\begin{table}[ht]
\begin{tabular}{cc}
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-a}\caption{Figure A}\label{fig:taba}\end{subfigure}&
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-b}\caption{Figure B}\label{fig:tabb}\end{subfigure}\\
\newline
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-c}\caption{Figure C}\label{fig:tabc}\end{subfigure}&
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-a}\caption{Figure A again}\label{fig:taba2}\end{subfigure}\\
\end{tabular}
\caption{A table with figures}
\label{tab:mytable}
\end{table}
}


But none of these options seem to be easy nor accurate enough. When you want to stack many things it becomes a mess.

I've found that ConTeXt has layers and they can be used to place accurately whatever thing wherever you want, telling it to locate figures at exact coordinates...

How can I do the same with LuaTeX or plain LateX?

I want to use this "collage" of figures or tables as the canvas to paint later with TikZ.

• you can specify the position of minipages (or anything else) using picture environment or tikz or any other command that prositions text by coordinates. – David Carlisle Nov 16 '17 at 17:34

You can use picture mode. Just make the bounding box zero size. Units are in pt, if I remember correctly.

\documentclass{article}
\usepackage{blindtext}
\usepackage{graphicx}

\begin{document}

\blindtext

\begin{picture}(0,0)
\put(0,0){$\bullet$\rlap{ Reference point}}
\put(150,50){\includegraphics[width=4cm]{example-image-a}}
\end{picture}

\blindtext

\end{document}