Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

LaTeX Two tikZ pictures side by side

  1. May 16, 2016 #1

    joshmccraney

    User Avatar
    Gold Member

    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?
     
  2. jcsd
  3. May 16, 2016 #2

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

  4. May 16, 2016 #3

    joshmccraney

    User Avatar
    Gold Member

    Yea, I clicked on the first several google suggestions, but notice the one that you reference has the minipage, and for some reason I can't seem to add a single caption for both pictures underneath. Any suggestions?
     
  5. May 16, 2016 #4

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Can you post some code?
     
  6. May 16, 2016 #5

    joshmccraney

    User Avatar
    Gold Member

    Sure, and I actually just found a way to do it using the subfigure package. Below is a working example:

    Code (Text):

    \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}
     
     
  7. May 17, 2016 #6

    joshmccraney

    User Avatar
    Gold Member

    Actually, while this is not the same question, perhaps you could help? For this line of code

    Code (Text):

    \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 (Text):

    \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?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Two tikZ pictures side by side
  1. Tikz Weighted Graphs (Replies: 0)

  2. LaTeX picture help (Replies: 1)

Loading...