[Tex/LaTex] Text alignment within tikzfigure environment of the tikzposter class

tikz-pgftikzposter

For my poster I am using the tikzfigure environment within tikzposter to add figures. It works fine, but I want to have the figure captions justified or left aligned instead of centered.

I have tried \justify or \begin{flushleft} ... \end{flushleft} within the caption, changing the tikzposter class file but it does not work.

MWE:

\documentclass[25pt, a0paper, landscape, margin=0mm, innermargin=50mm,
 blockverticalspace=15mm, colspace=30mm, subcolspace=8mm]{tikzposter} 
\geometry{paperwidth=100cm,paperheight=197cm} 
\makeatletter
\setlength{\TP@visibletextwidth}{\textwidth-2\TP@innermargin}
\setlength{\TP@visibletextheight}{\textheight-2\TP@innermargin}
\makeatother
\tikzposterlatexaffectionproofon 
% Commands
\newcommand{\bs}{\textbackslash}   
\newcommand{\cmd}[1]{{\bf \color{red}#1}}   
\usetheme{Simple}
\usebackgroundstyle{Empty}

\begin{document}

    \maketitle

 \begin{columns}%blocks will be placed into columns

                \column{.5}
                    \block{someblock1}{
                     \begin{tikzfigure}[\justify CAPTION HERE]
                     \includegraphics[width=0.40\colwidth] {images/someimage1.pdf}
                     \end{tikzfigure}      
            }

                \column{.5}
                    \block{someblock2}{
                    \begin{flushleft}
                    \begin{tikzfigure}[CAPTION HERE]
                    \includegraphics[width=0.40\colwidth] {images/someimage2.pdf}
                    \end{tikzfigure} 
                    \end{flushleft}
            }

 \end{columns}

 \end{document}

Thanks!

Best Answer

First version:

Put this in your preamble. Here the caption is aligned to the left starting with the figure:

\renewenvironment{tikzfigure}[1][]{
  \def \rememberparameter{#1}
  \vspace{10pt}
  \refstepcounter{figurecounter}
  \begin{center}
  \tabular{l}
  }{
    \ifx\rememberparameter\@empty
    \else %nothing
    \\[10pt]
    {\small Fig.~\thefigurecounter: \rememberparameter }
    \fi
  \endtabular
  \end{center}
}

enter image description here

Second version:

Here the caption is aligned totally to the left.

\renewenvironment{tikzfigure}[1][]{
  \def \rememberparameter{#1}
  \vspace{10pt}
  \refstepcounter{figurecounter}
  \begin{center}
  }{
    \ifx\rememberparameter\@empty
    \else %nothing
    \\[10pt]
    {\small Fig.~\thefigurecounter: \rememberparameter \hfill \mbox{}}
    \fi
  \end{center}
}

enter image description here

Code:

\documentclass[25pt, a0paper, landscape, margin=0mm, innermargin=50mm,
 blockverticalspace=15mm, colspace=30mm, subcolspace=8mm]{tikzposter}
\geometry{paperwidth=100cm,paperheight=197cm}
\makeatletter
\setlength{\TP@visibletextwidth}{\textwidth-2\TP@innermargin}
\setlength{\TP@visibletextheight}{\textheight-2\TP@innermargin}
\makeatother
\tikzposterlatexaffectionproofon
% Commands
\newcommand{\bs}{\textbackslash}
\newcommand{\cmd}[1]{{\bf \color{red}#1}}
\usetheme{Simple}
\usebackgroundstyle{Empty}

%\renewenvironment{tikzfigure}[1][]{
%  \def \rememberparameter{#1}
%  \vspace{10pt}
%  \refstepcounter{figurecounter}
%  \begin{center}
%  \tabular{l}
%  }{
%    \ifx\rememberparameter\@empty
%    \else %nothing
%    \\[10pt]
%    {\small Fig.~\thefigurecounter: \rememberparameter }
%    \fi
%  \endtabular
%  \end{center}
%}

\renewenvironment{tikzfigure}[1][]{
  \def \rememberparameter{#1}
  \vspace{10pt}
  \refstepcounter{figurecounter}
  \begin{center}
  }{
    \ifx\rememberparameter\@empty
    \else %nothing
    \\[10pt]
    {\small Fig.~\thefigurecounter: \rememberparameter \hfill \mbox{}}
    \fi
  \end{center}
}

\begin{document}

    \maketitle

 \begin{columns}%blocks will be placed into columns

                \column{.5}
                    \block{someblock1}{
                     \begin{tikzfigure}[CAPTION HERE]
                     \includegraphics[width=0.40\colwidth] {example-image}
                     \end{tikzfigure}
            }

                \column{.5}
                    \block{someblock2}{
                    \begin{flushleft}
                    \begin{tikzfigure}[CAPTION HERE]
                    \includegraphics[width=0.40\colwidth] {example-image}
                    \end{tikzfigure}
                    \end{flushleft}
            }

 \end{columns}

 \end{document}

If you want to do it on per figure basis you may use a \parbox

\documentclass[25pt, a0paper, landscape, margin=0mm, innermargin=50mm,
 blockverticalspace=15mm, colspace=30mm, subcolspace=8mm]{tikzposter}
\geometry{paperwidth=100cm,paperheight=197cm}
\makeatletter
\setlength{\TP@visibletextwidth}{\textwidth-2\TP@innermargin}
\setlength{\TP@visibletextheight}{\textheight-2\TP@innermargin}
\makeatother
\tikzposterlatexaffectionproofon
% Commands
\newcommand{\bs}{\textbackslash}
\newcommand{\cmd}[1]{{\bf \color{red}#1}}
\usetheme{Simple}
\usebackgroundstyle{Empty}


\begin{document}

    \maketitle

 \begin{columns}%blocks will be placed into columns

                \column{.5}
                    \block{someblock1}{
                     \begin{tikzfigure}[{\parbox[t]{0.39\colwidth}{CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE }}]
                     \includegraphics[width=0.40\colwidth] {example-image}
                     \end{tikzfigure}
            }

                \column{.5}
                    \block{someblock2}{
                    \begin{flushleft}
                    \begin{tikzfigure}[CAPTION HERE]
                    \includegraphics[width=0.40\colwidth] {example-image}
                    \end{tikzfigure}
                    \end{flushleft}
            }

 \end{columns}

 \end{document}

enter image description here

Please note that an extra pair of braces is needed surroung the \parbox in

\begin{tikzfigure}[{\parbox[t]{0.39\colwidth}{CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE CAPTION HERE }}]
Related Question