How to Place Two tikZ Pictures Side by Side?

  • Context: LaTeX 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Pictures
Click For Summary
SUMMARY

This discussion focuses on placing two tikZ pictures side by side in LaTeX using the subfigure package. The user initially attempted to use the \begin{minipage} command but struggled to add a single caption for both images. A solution was provided using the subcaption package, demonstrating how to effectively create side-by-side figures with individual captions and a collective caption. The provided LaTeX code illustrates the correct implementation of subfigures within a figure environment.

PREREQUISITES
  • Familiarity with LaTeX document preparation system
  • Understanding of tikZ for creating graphics in LaTeX
  • Knowledge of the subcaption package for figure captions
  • Basic experience with LaTeX figure environments
NEXT STEPS
  • Explore the subfigure package documentation for advanced figure placement techniques
  • Learn about the tikZ library for creating complex graphics in LaTeX
  • Investigate the use of the \resizebox command for scaling figures in LaTeX
  • Review LaTeX figure environments to understand positioning and captioning
USEFUL FOR

LaTeX users, graphic designers, and researchers who need to create and format multiple figures side by side in their documents.

member 428835
Hi PF!

I have been trying to put two tikZ pictures next to each other but I can't figure out how to do it. I've used the \begin{minipage} command, which worked well, but was unable to generate a caption. Any ideas?
 
Physics news on Phys.org
Can you post some code?
 
Sure, and I actually just found a way to do it using the subfigure package. Below is a working example:

Code:
\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption} 

\begin{document}
\begin{figure}
    \begin{subfigure}[b]{0.32\textwidth}
        \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \draw (2,2) circle (3cm);
            \end{tikzpicture}
        }
        \caption{Subfigure A}
        \label{fig:subfig8}
    \end{subfigure}
    \begin{subfigure}[b]{0.32\textwidth}
    \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \draw (2,2) circle (3cm);
            \end{tikzpicture}
        }
        \caption{Subfigure B}  
        \label{fig:subfig9}
    \end{subfigure}
    \begin{subfigure}[b]{0.32\textwidth}
        \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \draw (2,2) circle (3cm);
            \end{tikzpicture}
        }
        \caption{Subfigure C}
        \label{fig:subfig10}
    \end{subfigure}
\caption{big caption} 
\label{fig:subfig1.a.4}
\end{figure}

\end{document}
 
Actually, while this is not the same question, perhaps you could help? For this line of code

Code:
\draw[domain=0.1:1,samples=100,color=blue,variable=\x] plot (\x,{(\x)^(1/2)});

tikZ is plotting ##y=x^{-1/2}## and when I change the code to

Code:
\draw[domain=0.1:1,samples=100,color=blue,variable=\x] plot (\x,{1/(\x)^(1/2)});

tikZ is plotting ##y=x^{1/2}##. Any idea as to why this is?
 

Similar threads

  • · Replies 0 ·
Replies
0
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 7 ·
Replies
7
Views
9K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 14 ·
Replies
14
Views
5K
  • · Replies 1 ·
Replies
1
Views
5K