Previously I've had problems with 3D Tikz pictures having a lot of whitespace added to one side which was solved by using \documentclass[varwidth,border=5pt]{standalone}
.
Now, however, I'm trying to draw a 2D and 3D picture side-by-side. I can't just include the two pictures separately in the final document with the subcaption
package because of journal graphics requirements. Previously I was generating two separate pdfs of the pictures, then combining them into one pdf (for insertion into the final document) with another .tex file. This seems like a convoluted way of doing things though.
Here's my MWE:
\documentclass[varwidth,border=5pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows}
\usetikzlibrary{3d}
\tikzset{>=latex}
\begin{document}
\begin{tikzpicture}
\draw[-] (0,0)--(3,0)--(3,2)--(0,2)--cycle;
\draw[-] (0,2)--(3,2)--(3,4)--(0,4)--cycle;
\draw[-] (0,4)--(3,4)--(3,6)--(0,6)--cycle;
\node at (-0.4,5.7) {{\large a}};
\end{tikzpicture}
\tdplotsetmaincoords{90}{90}
\tdplotsetrotatedcoords{0}{20}{70}
\begin{tikzpicture}[tdplot_rotated_coords]
\draw[->, thick] (0,0,0) --++ (20:3);
\draw[->] (0,0,0) --++ (60:2);
\draw[dashed] (0,0,-2) circle(2);
\draw[dashed] (0,0,0) circle(2);
\draw[dashed] (0,0,2) circle(2);
\node[left] at (0,0,0) {{ $i$}};
\node[right] at (2.2,0.15,-0.05) {{\large {\bf M}}};
\node[below] at (0.5,0.5,0) {{\large $\phi_i$}};
\draw[->] (0,0,-2) -- (0,0,3.5);
\node[above] at (0,0,3.5) {{\large $z$}};
\node at (-2,0,3.5) {{\large b}};
\end{tikzpicture}
\end{document}
If you compile it as it is, the two tikz pictures align one above the other. I think that's because of the varwidth
argument. If you take that out the pictures are side-by-side but the whitespace associated with the 3D picture appears, so the two are separated by a large gap.
Does anyone know the best way around this?
Thanks.
Best Answer
2nd version:
So the problem seems to include different figures in one pdf file. There are several solutions but as you use
standalone
class andTiKZ
you just need to includetikz
as an option to your original example (\documentclass[tikz,varwidth,border=5pt]{standalone}
) and will get a pdf file with as many pages astikzpictures
. You can include figures in your text with\includegraphics[page=...]{...}
.Original answer:
I don't understand the problem you have with the journalgraphics requirements but if you want to place both figures side by side with
varwidth
option one possible solution can be to draw both figures inside the sametikzpicture
with one of them inside a properly placedscope
.Note:
shift
values have been found by trial and error.