# How to create a word/equation/diagram collage

I'm looking to create a collage of sorts with various equations as well as some commutative diagrams. I normally use tikzcd to make diagrams so if I can use that here it would be helpful. The end goal would be something like this:

Specifically, I'm wondering how to:

1. Place expressions in arbitrary locations
2. Place text in arbitrary locations
3. Include diagrams and possibly pictures

I don't know if it makes any difference, but I normally work in overleaf.

Additional things which would be neat but not really necessary: Changing page/text color (like in the image) and rotating equations.

This question is very similar but it has no answers and I'm not sure I understand the approach the OP took.

I also saw this but I'm having a hard time figuring out how to use beamer. However, I think it may be doable. What are some tips to using beamer to do this sort of thing? Or is there a better way?

• You could do something like this, perhaps with more \parbox with mathematics and less high quality artwork tex.stackexchange.com/a/213293/1090 Feb 12, 2021 at 0:13
• Do you want to do it by hand or automatically? Looks doable via MetaPost and a lot of randomizers, but it depends on your willingness to use MetaPost... TikZ would perform too slowly in comparison
– user226564
Feb 12, 2021 at 23:11
• @JairoA.delRio By hand, since I would like precise control over placement of images/text. I'm not familiar with MetaPost, but I'd be willing to learn it (I have no time limit, this is just for fun). Feb 12, 2021 at 23:58

It's a fitting job for xcoffins. It is a package created to facilitate the layout of stuff on the page: text, tables, images, graphics, etc., in a very simple way. Handy to construct cover and title pages, and collages...

It works like a graphic design program (almost, no GUI, you have to compile to see the changes) in the sense that it uses the relative positions of the objects, rather than absolute coordinates.

You put the material in special boxes that have several handles (in the corners, in the middle of the sides, in the center and others) that allow you to join the handle of one box with a handle of another box. For example, the lower left corner of the first with the upper left corner of the second: [hc,b] refers to a point at the bottom and the horizontal center of the box, [hc,t] refers to point at the top and the horizontal center of the box, etc.

On top of that, you can add vertical and horizontal offsets to position the content exactly where you want it.

I collected several examples: a table, figures, text (the title), equations, tikz pictures and tikz-cd, and assembled all them (15 objects) using a large box the size of the text area, like a frame (called \Framex, light blue) to collect the others. A couple were rotated.

All the material will go on top of the frame. After all the joins are completed, the frame is typeset on a single page as a text object (it is not a float).

I included a table with the dimensions of the boxes (using the tools provided by xcoffins plus a macro to convert pt to cm), before the assembly process. It might be helpful to build a mock-up model with paper rectangles to find the best arrangement.

I recommend doing one merge (Join) at a time and compiling, to see how the box fits together and if offsets are needed. The process is very fast once you understand the name of the basic identifiers of the handles using the letters l, r, t, b, vc, hc.

I also recommend reading the manual on the package, replicating the example for a quick learning curve.

How do I binpack a set of tables on a page?

This is the code.

\documentclass[12pt,a4paper]{article}

\usepackage{graphicx}
\usepackage[left=1.00cm, right=1.00cm, top=2.00cm, bottom=1.00cm]{geometry}

\usepackage{xcolor}
\usepackage{xcoffins}

\usepackage{pgfplots}
\usepackage{tikz-cd}
\usepackage{mathtools}
\usepackage{amssymb}

%https://tex.stackexchange.com/questions/99550/how-do-i-convert-pt-in-cm-mm-to-em-ex-as-they-are-defined-at-a-given-point-in-th
\ExplSyntaxOn
\NewDocumentCommand{\convertto}{mm}
% #1 = em or ex (or any other unit)
% #2 = dimen to convert
{
\texttt{#2~=~\fp_to_decimal:n { round ( (#2)/(1#1), 5 ) }#1}
}
\DeclareExpandableDocumentCommand{\thelength}{ O{mm} m }
{
\fp_to_decimal:n { round ( #2/1#1, 1 ) } #1
}
\ExplSyntaxOff

\NewCoffin\Framex
\NewCoffin\figi
\NewCoffin\tkzii
\NewCoffin\tkziii
\NewCoffin\tkziv
\NewCoffin\tkzv
\NewCoffin\tblvi
\NewCoffin\tkzvii
\NewCoffin\tkzviii
\NewCoffin\eqix
\NewCoffin\tkzx
\NewCoffin\figxi
\NewCoffin\tkzxii
\NewCoffin\eqxiii
\NewCoffin\txtxiv
\NewCoffin\eqxv

\begin{document}

%% Filling the boxes    <<<<<<<<<<<<<<<

\SetHorizontalCoffin\Framex{\color{blue!10}\rule{\textwidth}{0.95\textheight}}

\SetHorizontalCoffin\figi{%
\includegraphics[scale=0.3]{example-image-a}
}

\SetHorizontalCoffin\tkzii{%
\begin{tikzpicture}[thick,yscale=1]
\draw[->]   (0,2) -- (0,4) node[above]{$\cos{\bigl(\frac{\pi}{L} x\bigr)}$} ;
\draw[->]   (-3,3) -- (3,3) node[right]{$x$} ;
\draw[very thick,line cap=round,domain=-2:2, color=green] plot[samples=200] (\x, {3+2/3*cos(\x*45)}) ;
\draw       (-2,3.1) -- (-2,2.9)    (2,3.1) -- (2,2.9)  (2.5,3.75) node{$m_x=\frac{1}{2}$} ;
\draw[->]   (0,-1) -- (0,1) node[above]{$\sin{\bigl(\frac{2\pi}{L} x\bigr)}$} ;
\draw[->]   (-3,0) -- (3,0) node[right]{$x$} ;
\draw[very thick,line cap=round,domain=-2:2,color=red]plot[samples=200] (\x, {2/3*sin(\x*90)}) ;
\draw       (-2,.1) -- (-2,-.1)     (2,.1) -- (2,-.1)(2.5,.75) node{$m_x=1$} ;
\draw[->]   (0,-4) -- (0,-2) node[above]{$\cos{\bigl(\frac{3\pi}{L} x\bigr)}$} ;
\draw[->]   (-3,-3) -- (3,-3) node[right]{$x$} ;
\draw[very thick,line cap=round,domain=-2:2,color=blue]plot[samples=200] (\x, {-3+2/3*cos(\x*135)}) ;
\draw   (-2,-2.9) -- (-2,-3.1)  (2,-2.9) -- (2,-3.1)(2.5,-2.25) node{$m_x=\frac{3}{2}$} ;
\end{tikzpicture}
}

\SetHorizontalCoffin\tkziii{%
\begin{tikzcd}[ampersand replacement=\&]
A \arrow{r}{\varphi} \arrow[swap]{d}{\varrho_f} \& B \arrow{d}{\varrho_g} \\%
A_f \arrow{r}{\varphi_f}\& B_g
\end{tikzcd}
}

\SetHorizontalCoffin\tkziv{%
\begin{tikzcd}[swap, ampersand replacement=\&]
F_t(x) \arrow[Rightarrow]{r}[inner sep = 1ex]{\mathcal{B}_T}
\arrow{d}{\mathcal{B}'_X}
\& F(x) \arrow{d}[swap]{\mathcal{B}_X}{\exists} \\
A_t \arrow{r}[swap]{\exists}{\mathcal{B}_T} \arrow[dashed,dash]{ur}
\& A
\end{tikzcd}
}

\SetHorizontalCoffin\tkzv{%
\begin{tikzcd}[row sep={40,between origins}, column sep={40,between origins},  ampersand replacement=\&]
\& X_1 \times_{S_1} Y_1 \ar{rr}\ar{dd}\ar{dl} \&  \& Y_1\vphantom{\times_{S_1}} \ar{dd}\ar{dl} \\
X_1 \ar[crossing over]{rr} \ar{dd} \& \& S_1 \\
\& X_2 \times_{S_2} Y_2  \ar{rr} \ar{dl} \& \&  Y_2\vphantom{\times_{S_1}} \ar{dl} \\
X_2 \ar{rr} \&\& S_2 \ar[from=uu,crossing over]
\end{tikzcd}
}

\SetHorizontalCoffin\tblvi{%
\scriptsize
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& & \multicolumn{3}{|c|}{Particle Type} & Hcharge \\
\hline
& Quarks & $u$ & $c$ & $t$ & $1/6$ \\
Left &  & $d$ & $s$ & $b$ & $1/6$ \\
Handed & Leptons & $\nu_{e}$ & $\nu_{\mu}$ & $\nu_{\tau}$ & $-1/2$\\
& & $e$ & $\mu$ & $\tau$ & $-1/2$ \\
\hline \hline
& Quarks & $u$ & $c$  & $t$ & $2/3$\\
Right & & $d$ & $s$ & $b$ & $-1/3$\\
Handed & Leptons & & & &\\
& & $e$ & $\mu$ & $\tau$ & $-1$\\
\hline
\end{tabular}
}

\SetHorizontalCoffin\tkzvii{%
\begin{tikzpicture}[
declare function={a(\x)=(\x/10)^2;},
declare function={b(\x)=-(\x/10)^2-10;},
]
\begin{axis}[
domain=0:10, xmin=0,
axis lines=middle,
axis equal image,
xtick=\empty, ytick=\empty,
enlargelimits=true,
clip mode=individual, clip=false
]
\addplot [red, only marks, mark=*, samples=500, mark size=0.75]  %large con 500000
(f(x), {0.5*(a(x)+b(x)) + rand * ( a(f(x)) - b(f(x))) / 2});
\end{axis}
\end{tikzpicture}
}

\SetHorizontalCoffin\tkzviii{%
\begin{tikzpicture}[node distance=2cm, auto]
\node (C) {$C$};
\node (P) [below of=C] {$\prod_{i \in I} A_i$};
\node (Ai) [right of=P] {$A_i$};
\draw[->,color=red] (C) to node {$f_i$} (Ai);
\draw[->, dashed] (C) to node [swap] {$\langle f_i \rangle_{i \in I}$} (P);
\draw[->, color=green] (P) to node [swap] {$\pi_i$} (Ai);
\end{tikzpicture}
}

\SetVerticalCoffin\eqix{0.6\textwidth}{%
\begin{eqnarray}
\int_{-\infty}^{\infty} e^{\pm j2\pi ft}\;dt
&=&\int_{-\infty}^{\infty} \cos(2\pi ft)\;dt\pm j\int_{-\infty}^{\infty} \sin(2\pi ft)\;dt
\nonumber \\
&=&2\int_0^{\infty} \cos(2\pi ft)\;dt=\delta(f)=2\pi \delta(\omega).
\end{eqnarray}
}

\SetHorizontalCoffin\tkzx{%
\begin{tikzpicture}
\begin{axis}[only marks, mark size=1.5pt,domain=1:10,scale=0.6]
({cos(rnd r)*x+rnd},{(rnd+1)*x+rnd});
\end{axis}
\end{tikzpicture}
}

\SetHorizontalCoffin\figxi{%
\includegraphics[height=100pt,width=100pt]{example-grid-100x100pt}
}

\SetHorizontalCoffin\tkzxii{%
\begin{tikzpicture}[xscale=-1,yscale=0.5,remember picture]
\begin{axis}[hide axis,width=8cm,height=4cm,clip=false]
color(16cm)=(blue);
},
ultra thick, point meta=x*x,mesh]{sin(pow(x,2)/15)};
\end{axis}
\end{tikzpicture}
}

\SetVerticalCoffin\eqxiii{200pt}{%
$\Psi(x) \rightarrow \Psi^{\prime}(x) = e^{-i\omega^a(x) \mathbf{t}^a} \Psi(x)$\\
where the $\mathbf{t}^a$ are the $N^2 - 1$ generators of the group. These generators, $\mathbf{t}^a$, have a distinct algebra \\
$[\mathbf{t}^a,\mathbf{t}^b] = if^{abc}\mathbf{t}^c$
}

\SetVerticalCoffin\txtxiv{0.4\textwidth}{%
\centering \bfseries \Large A collage of equations, figures, tikz pictures, text and tables using {\color{red} xcoffins}
}

\SetVerticalCoffin\eqxv{0.3\textwidth}{%
\small
$s= \left(k_1 + k_2 \right)^2$\\
The Lorentz invariant phase space for the outgoing state, $d\Phi_N$, \\ is given by\\
$d\Phi_N = \left(2\pi \right)^4 \delta^4\left(k_{1} + k_2 - \Sigma_i^N k_i \right)$ \\
$\prod_{i}^{N} \frac{d^4 k_i}{\left(2\pi \right)^4} \left(2\pi\right) \delta \left(k_i^2 - m_i^2 \right)$
}

%%  Joining the boxes to the frame  and adding offsets <<<<<<<<<<<<<<<<<<<<<<<<<,

\JoinCoffins\Framex[l,t]\figi[l,t]

\JoinCoffins\Framex[hc,t]\tkzii[hc,t](-50pt,0pt)

\JoinCoffins\Framex[l,t]\tkziii[l,t](0pt,-80pt)

\JoinCoffins\Framex[r,t]\tkziv[r,t](0pt,-120pt)

\JoinCoffins\Framex[hc,vc]\tkzv[hc,vc](0pt,-70pt)

\JoinCoffins\Framex[r,vc]\tblvi[r,vc](0pt,-150pt)

\RotateCoffin\tkzvii{60}
\JoinCoffins\Framex[l,vc]\tkzvii[l,t](0pt,-50pt)

\JoinCoffins\Framex[l,t]\tkzviii[l,t](0pt,-180pt)

\RotateCoffin\eqix{90}
\JoinCoffins\Framex[r,vc]\eqix[r,b](-110pt,250pt)

\JoinCoffins\Framex[hc,b]\tkzx[hc,b](0pt,0pt)

\JoinCoffins\Framex[l,b]\figxi[l,b]

\JoinCoffins\Framex[r,vc]\tkzxii[r,vc](0pt,-235pt)

\JoinCoffins\Framex[l,vc]\eqxiii[l,vc](0pt,-180pt)

\JoinCoffins\Framex[r,t]\txtxiv[r,t](0pt,-10pt)

\JoinCoffins\Framex[r,b]\eqxv[r,b](-10pt,5pt)

%%  Typeset the assembly in the left margin of the first line  <<<<<<<<<<<<<<<
\noindent\TypesetCoffin\Framex

\section*{Heights and widths}
\begin{tabular}{lrr}
\hline
ID & height & width \\
\hline
figi    &\thelength[mm]{\CoffinTotalHeight\figi}    & \thelength[mm]{\CoffinWidth\figi}     \\
tkzii   & \thelength[mm]{\CoffinTotalHeight\tkzii}  & \thelength[mm]{\CoffinWidth\tkzii}    \\
tkziii  & \thelength[mm]{\CoffinTotalHeight\tkziii} & \thelength[mm]{\CoffinWidth\tkziii}   \\
tkziv   & \thelength[mm]{\CoffinTotalHeight\tkziv}  & \thelength[mm]{\CoffinWidth\tkziv}    \\
tkzv    & \thelength[mm]{\CoffinTotalHeight\tkzv}   & \thelength[mm]{\CoffinWidth\tkzv}     \\
tblvi   & \thelength[mm]{\CoffinTotalHeight\tblvi}  & \thelength[mm]{\CoffinWidth\tblvi}    \\
tkzvii  & \thelength[mm]{\CoffinTotalHeight\tkzvii} & \thelength[mm]{\CoffinWidth\tkzvii}   \\
tkzviii & \thelength[mm]{\CoffinTotalHeight\tkzviii}& \thelength[mm]{\CoffinWidth\tkzviii}  \\
eqix    & \thelength[mm]{\CoffinTotalHeight\eqix}   & \thelength[mm]{\CoffinWidth\eqix}     \\
tkzx    & \thelength[mm]{\CoffinTotalHeight\tkzx}   & \thelength[mm]{\CoffinWidth\tkzx}     \\
figxi   & \thelength[mm]{\CoffinTotalHeight\figxi}  & \thelength[mm]{\CoffinWidth\figxi}    \\
tkzxii  & \thelength[mm]{\CoffinTotalHeight\tkzxii} & \thelength[mm]{\CoffinWidth\tkzxii}   \\
eqxiii  & \thelength[mm]{\CoffinTotalHeight\eqxiii} & \thelength[mm]{\CoffinWidth\eqxiii}   \\
txtxiv  & \thelength[mm]{\CoffinTotalHeight\txtxiv} & \thelength[mm]{\CoffinWidth\txtxiv}   \\  % title
eqxv    & \thelength[mm]{\CoffinTotalHeight\eqxv}   & \thelength[mm]{\CoffinWidth\eqxv}     \\
\hline
\end{tabular}

\end{document}