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

Discussion Overview

The thread discusses methods for placing two tikZ pictures side by side in LaTeX, focusing on the use of the minipage command and the subfigure package. Participants explore challenges related to captioning and seek solutions for displaying multiple figures together.

Discussion Character

  • Technical explanation, Debate/contested, Homework-related

Main Points Raised

  • One participant mentions using the \begin{minipage} command but struggles to add a single caption for both pictures.
  • Another participant provides a link to a resource on placing tikZ pictures side by side, which also references the minipage method.
  • A participant shares a working example using the subfigure package, successfully demonstrating how to place multiple tikZ pictures side by side with a collective caption.
  • Another participant introduces a different issue regarding the plotting of functions in tikZ, questioning why a specific line of code produces an unexpected output.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method for placing tikZ pictures side by side, as some prefer the minipage approach while others find the subfigure package more effective. Additionally, the discussion introduces a separate issue regarding function plotting in tikZ, which remains unresolved.

Contextual Notes

Participants express uncertainty about the limitations of the minipage method concerning captions and the behavior of tikZ when plotting certain functions. The discussion does not clarify these issues fully.

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
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · 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