3

I have the following code with two tikz pictures (I am not an expert sorry if it can be simplified)

\documentclass{article}
\usepackage{tikz}

\usepackage[
format={hang},
figurename=Figura,
labelfont={bf,normalsize},
textfont={small},
labelsep=quad,
justification={justified},
width=.75\textwidth
]{caption}

\usepackage[
labelfont={bf,normalsize},
labelformat=parens,
labelsep=none,
]{subcaption}


\begin{figure}[H]
\centering
\begin{subfigure}{.2\linewidth}
    \begin{tikzpicture}[line width=1.5pt]
    \draw[black,fill=cyan] (0,0) -- (2cm,0) arc (0:45:2cm) -- cycle;
    \draw[black,fill=cyan] (0,0) -- (45:2cm) arc (45:90:2cm) -- cycle; 
    \draw[black,fill=cyan] (0,0) -- (90:2cm) arc (90:135:2cm) --cycle;
    \draw[black] (0,0) -- (135:2cm) arc (135:180:2cm) --cycle;  
    \draw[black] (0,0) -- (180:2cm) arc (180:225:2cm) --cycle; 
    \draw[black] (0,0) -- (225:2cm) arc (225:270:2cm) --cycle; 
    \draw[black] (0,0) -- (270:2cm) arc (270:315:2cm) --cycle; 
    \draw[black] (0,0) -- (315:2cm) arc (315:360:2cm) --cycle; 
    \end{tikzpicture}
    \caption{}
\end{subfigure}
\hspace{4cm}
\begin{subfigure}{.2\linewidth}
    \begin{tikzpicture}[line width=1.5pt]
    \draw[black,fill=orange] (0,0) -- (2cm,0) arc (0:30:2cm) -- cycle;
    \draw[black,fill=orange] (0,0) -- (30:2cm) arc (30:60:2cm) -- cycle; 
    \draw[black,fill=orange] (0,0) -- (60:2cm) arc (60:90:2cm) --cycle;
    \draw[black,fill=orange] (0,0) -- (90:2cm) arc (90:120:2cm) --cycle;  
    \draw[black,fill=orange] (0,0) -- (120:2cm) arc (120:150:2cm) --cycle; 
    \draw[black,fill=orange] (0,0) -- (150:2cm) arc (150:180:2cm) --cycle; 
    \draw[black,fill=orange] (0,0) -- (180:2cm) arc (180:210:2cm) --cycle; 
    \draw[black] (0,0) -- (210:2cm) arc (210:240:2cm) --cycle;
    \draw[black] (0,0) -- (240:2cm) arc (240:270:2cm) --cycle; 
    \draw[black] (0,0) -- (270:2cm) arc (270:300:2cm) --cycle;
    \draw[black] (0,0) -- (300:2cm) arc (300:330:2cm) --cycle;
    \draw[black] (0,0) -- (330:2cm) arc (330:360:2cm) --cycle;
    \end{tikzpicture}
    \caption{}
\end{subfigure}
\caption{Some text}
\end{figure}

The problem is that the caption of both subfigures is not vertically aligned with the center of the circles. How can I achieve this? I tried playing with the indention and margin option of the subcaption but nothing worked

2

Adjust the width of the subfigure-minipages, they are too narrow right now. I guess you want those circles centered, add \centering.

very23MinipageAlignCaption

\documentclass{article}
\usepackage{tikz}

\usepackage[
    format={hang},
    figurename=Figura,
    labelfont={bf,normalsize},
    textfont={small},
    labelsep=quad,
    justification={justified},
    width=.75\textwidth
]{caption}

\usepackage[
    labelfont={bf,normalsize},
    labelformat=parens,
    labelsep=none,
]{subcaption}


\begin{document}
\begin{figure}
    \centering
    \begin{subfigure}{.4\linewidth}
        \centering
        \begin{tikzpicture}[line width=1.5pt]
            \draw[black,fill=cyan] (0,0) -- (2cm,0) arc (0:45:2cm) -- cycle;
            \draw[black,fill=cyan] (0,0) -- (45:2cm) arc (45:90:2cm) -- cycle; 
            \draw[black,fill=cyan] (0,0) -- (90:2cm) arc (90:135:2cm) --cycle;
            \draw[black] (0,0) -- (135:2cm) arc (135:180:2cm) --cycle;  
            \draw[black] (0,0) -- (180:2cm) arc (180:225:2cm) --cycle; 
            \draw[black] (0,0) -- (225:2cm) arc (225:270:2cm) --cycle; 
            \draw[black] (0,0) -- (270:2cm) arc (270:315:2cm) --cycle; 
            \draw[black] (0,0) -- (315:2cm) arc (315:360:2cm) --cycle; 
        \end{tikzpicture}
        \caption{}
    \end{subfigure}\hfill
    \begin{subfigure}{.4\linewidth}
    \centering
        \begin{tikzpicture}[line width=1.5pt]
            \draw[black,fill=orange] (0,0) -- (2cm,0) arc (0:30:2cm) -- cycle;
            \draw[black,fill=orange] (0,0) -- (30:2cm) arc (30:60:2cm) -- cycle; 
            \draw[black,fill=orange] (0,0) -- (60:2cm) arc (60:90:2cm) --cycle;
            \draw[black,fill=orange] (0,0) -- (90:2cm) arc (90:120:2cm) --cycle;  
            \draw[black,fill=orange] (0,0) -- (120:2cm) arc (120:150:2cm) --cycle; 
            \draw[black,fill=orange] (0,0) -- (150:2cm) arc (150:180:2cm) --cycle; 
            \draw[black,fill=orange] (0,0) -- (180:2cm) arc (180:210:2cm) --cycle; 
            \draw[black] (0,0) -- (210:2cm) arc (210:240:2cm) --cycle;
            \draw[black] (0,0) -- (240:2cm) arc (240:270:2cm) --cycle; 
            \draw[black] (0,0) -- (270:2cm) arc (270:300:2cm) --cycle;
            \draw[black] (0,0) -- (300:2cm) arc (300:330:2cm) --cycle;
            \draw[black] (0,0) -- (330:2cm) arc (330:360:2cm) --cycle;
        \end{tikzpicture}
        \caption{}
    \end{subfigure}
    \caption{Some text}
\end{figure}
\end{document}
|improve this answer|||||
  • Thanks it did the work I didn't think about the width – Very23 Jun 19 '15 at 18:09
3

Use \subcaptionbox, so you don't have to guess the size of the subfigures.

\documentclass{article}
\usepackage{tikz}

\usepackage[
  format=hang,
  figurename=Figura,
  labelfont=bf,
  font=small,
  labelsep=quad,
  justification={justified},
  width=.75\textwidth
]{caption}

\usepackage[
  labelfont={bf,small},
  labelformat=parens,
  labelsep=none,
]{subcaption}

\begin{document}

\begin{figure}[htp]
\centering
\subcaptionbox{}{%
    \begin{tikzpicture}[line width=1.5pt]
    \draw[black,fill=cyan] (0,0) -- (2cm,0) arc (0:45:2cm) -- cycle;
    \draw[black,fill=cyan] (0,0) -- (45:2cm) arc (45:90:2cm) -- cycle; 
    \draw[black,fill=cyan] (0,0) -- (90:2cm) arc (90:135:2cm) --cycle;
    \draw[black] (0,0) -- (135:2cm) arc (135:180:2cm) --cycle;  
    \draw[black] (0,0) -- (180:2cm) arc (180:225:2cm) --cycle; 
    \draw[black] (0,0) -- (225:2cm) arc (225:270:2cm) --cycle; 
    \draw[black] (0,0) -- (270:2cm) arc (270:315:2cm) --cycle; 
    \draw[black] (0,0) -- (315:2cm) arc (315:360:2cm) --cycle; 
    \end{tikzpicture}%
}%
\hspace{2cm}%
\subcaptionbox{}{%
    \begin{tikzpicture}[line width=1.5pt]
    \draw[black,fill=orange] (0,0) -- (2cm,0) arc (0:30:2cm) -- cycle;
    \draw[black,fill=orange] (0,0) -- (30:2cm) arc (30:60:2cm) -- cycle; 
    \draw[black,fill=orange] (0,0) -- (60:2cm) arc (60:90:2cm) --cycle;
    \draw[black,fill=orange] (0,0) -- (90:2cm) arc (90:120:2cm) --cycle;  
    \draw[black,fill=orange] (0,0) -- (120:2cm) arc (120:150:2cm) --cycle; 
    \draw[black,fill=orange] (0,0) -- (150:2cm) arc (150:180:2cm) --cycle; 
    \draw[black,fill=orange] (0,0) -- (180:2cm) arc (180:210:2cm) --cycle; 
    \draw[black] (0,0) -- (210:2cm) arc (210:240:2cm) --cycle;
    \draw[black] (0,0) -- (240:2cm) arc (240:270:2cm) --cycle; 
    \draw[black] (0,0) -- (270:2cm) arc (270:300:2cm) --cycle;
    \draw[black] (0,0) -- (300:2cm) arc (300:330:2cm) --cycle;
    \draw[black] (0,0) -- (330:2cm) arc (330:360:2cm) --cycle;
    \end{tikzpicture}%
}
\caption{Some text}
\end{figure}

\end{document}

I changed some settings: it doesn't make sense that the label “Figura 1” has a bigger font size than the caption; I also reduced the font size in the subcaptions to match.

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.