2

I'm trying to use sub-figures in a figure, within a block, that's in a column, on a tikzposter and instead of placing the figure and caption within the block they appear outside of it, in the middle of the poster (see picture)enter image description here. How do I get them to stay in the block?

\documentclass[24pt, a1paper, landscape]{tikzposter}
\usepackage[utf8]{inputenc}

\usepackage[labelfont=bf]{caption}
\captionsetup{font=small}

\usepackage{float}
\usepackage{graphicx}
\usepackage{subcaption}


\title{\textbf{title}}
\author{me}
\date{}
\institute{\small{institute}}


\begin{document}

\maketitle
 \node[above right,opacity=0.65,inner sep=0pt,outer sep=0pt] at (bottomleft) 
{\includegraphics[width=\paperwidth,height=\paperheight]{backgroundsample}};

\block{\textbf{Text}}
{
Some Text  
}
\begin{columns}
\column{0.3}
\block{Also Text}
{
More Text Here

\begin{figure}[H]
\centering
\begin{subfigure}{0.15\textwidth}
\centering
\includegraphics[width=0.7\linewidth]{sample}
\caption{\textit{subcaption}}
\label{fig:1a}
\end{subfigure}%
\begin{subfigure}{0.15\textwidth}
\centering
\includegraphics[width=0.85\linewidth]{sample}
\caption{\textit{subcaption}}
\label{fig:1b}
\end{subfigure}
\caption{\textit{Some caption here}}
\label{fig:1}
\end{figure}



}
\end{columns}
\end{document}
  • 2
    Welcome to StackExchange - and thanks for posting a MWE! – Jesse Knight Mar 22 at 16:48
1

Unfortunately, float environments do not work in tikzposter.

The general solution for defining figures and subfigures in tikzposter is:

% preamble
\usepackage{subcaption} -> \usepackage{subfigure}   % for subfigure captions
...
% body
\begin{figure} -> \begin{tikzfigure}                % figure environment
\begin{subcaption}{...} -> \begin{minipage}{...}    % subfigure environment
\caption{...} -> \captionof{figure}{...}            % figure captions
\caption{...} -> \captionof{subfigure}{...}         % subfigure captions

So, for your example (changes marked with % <-):

\documentclass[24pt, a1paper, landscape]{tikzposter}
\usepackage[utf8]{inputenc}

\usepackage[labelfont=bf]{caption}
\captionsetup{font=small}

\usepackage{float}
\usepackage{graphicx}
\usepackage{subfigure} % <-


\title{\textbf{title}}
\author{me}
\date{}
\institute{\small{institute}}


\begin{document}

\maketitle
\node[above right,opacity=0.65,inner sep=0pt,outer sep=0pt] at (bottomleft) {};
% {\includegraphics[width=\paperwidth,height=\paperheight]{backgroundsample}}; % for now

\block{\textbf{Text}}
{
Some Text  
}
\begin{columns}
\column{0.3}
\block{Also Text}
{
More Text Here

\begin{tikzfigure} % <-
\centering
\begin{minipage}{0.12\textwidth} % <-
\centering
\includegraphics[width=0.7\linewidth]{sample}
\captionof{subfigure}{\textit{subcaption}} % <-
\label{fig:1a}
\end{minipage}% % <-
\begin{minipage}{0.12\textwidth} % <-
\centering
\includegraphics[width=0.85\linewidth]{sample}
\captionof{subfigure}{\textit{subcaption}} % <-
\label{fig:1b}
\end{minipage} % <-
\captionof{figure}{\textit{Some caption here}} % <-
\label{fig:1}
\end{tikzfigure} % <-


}
\end{columns}
\end{document}

which yields:

(I also: 1. commented out the background image, 2. adjusted the sizes of the subfigures to fit, 3. removed [H] as it is not necessary with tikzfigure)

result

  • UPDATE: the solution proposed by @John Kormylo is much better, as it allows you to make correct \ref calls. This solution will not give the right numberings -- e.g. try \ref{fig:1a}. Please accept the other answer and not mine. – Jesse Knight Mar 22 at 17:53
1

The tikzposter manual says "Due to implementation of the blocks, using the standard LaTeX figure environment is not possible." It provides a tikzfigure environment, but tikzposter does not really support \caption or subfigures.

The remaining question is what to use for the width. It appears that \textwidth and \columnwidth are too wide. \linewidth works, but makes 0.15\textwidth very small indeed.

\documentclass[24pt, a1paper, landscape]{tikzposter}
\usepackage[utf8]{inputenc}

\usepackage[labelfont=bf]{caption}
\captionsetup{font=small}

%\usepackage{float}
\usepackage{graphicx}
\usepackage{subcaption}
\makeatletter
\newenvironment{myfigure}{\minipage{\linewidth}\def\@captype{figure}}{\endminipage}
\makeatother

\title{\textbf{title}}
\author{me}
\date{}
\institute{\small{institute}}


\begin{document}

\maketitle
 \node[above right,opacity=0.65,inner sep=0pt,outer sep=0pt] at (bottomleft) 
{\includegraphics[width=\paperwidth,height=\paperheight]{example-image}};

\block{\textbf{Text}}
{
Some Text  
}
\begin{columns}
\column{0.3}
\block{Also Text}
{
More Text Here

\begin{myfigure}
\centering
\begin{subfigure}{0.15\textwidth}
\centering
\includegraphics[width=0.7\linewidth]{example-image-a}
\caption{\textit{subcaption}}
\label{fig:1a}
\end{subfigure}%
\begin{subfigure}{0.15\textwidth}
\centering
\includegraphics[width=0.85\linewidth]{example-image-b}
\caption{\textit{subcaption}}
\label{fig:1b}
\end{subfigure}
\caption{\textit{Some caption here}}
\label{fig:1}
\end{myfigure}

}
\end{columns}
\end{document}

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.