2

Some time ago now, I answered this question Tikzposter block with no content And I thought all was nice and good.

But after having had to use the command I created I realized that around 2cm of blank space is inserted in after any titleblock. This can bee fixed with the titleoffsety=2cm and bodyoffsety=2cm on any top block right below the title block. To streamline this I could make an aftertitleblock that adds this, but it seems like a dirty macro if I need to make a new macro to clean after myself.

So I was wondering if there was a way to remove the 2cm of emptyness, from within the defineblockstyle command.

MWE:

\documentclass{tikzposter}
\defineblockstyle{Justtitle}{
        }{
        \ifBlockHasTitle
                \draw[color=framecolor, fill=blocktitlebgcolor,
                rounded corners=\blockroundedcorners] (blocktitle.south west)
                rectangle (blocktitle.north east);
        \fi
}
\newcommand{\titleblock}[1]{\useblockstyle{Justtitle}\block{#1}{}\useblockstyle{Default}}

\begin{document}
\titleblock{Cool title}
\begin{columns}
        \column{0.5}
        \block[titleoffsety=2cm,bodyoffsety=2cm]{cool block title}{block text} %NOTE THE OFFSET
        \block{next block}{more text}
        \column{0.5}
        \block{even cooler, but wrongly placed title}{Super cool text here}%NOTE THE LACK OF OFFSET
        \block{hello}{duck}
\end{columns}
\end{document}

Produces: A picture Yay

  • I don't completely understand the code (tikzposter.cls, line 399) but I think that even when body is empty, some parbox is defined for it and space is reserved. This can be seen in your solution where there's some space below bob box. – Ignasi Jun 11 '18 at 13:22
  • And discrepancies between title and body heights in samcarter solution are due to block linewidth which are always drawn behind|around boxes text. – Ignasi Jun 11 '18 at 13:25
  • @Ignasi I figured that it always defined them, but I was wondering wether or not I could define the titleblock command to remove them afterwards? – Thorbjørn E. K. Christensen Jun 11 '18 at 15:53
  • You can always investigate how high is an empty box and apply the corresponding shift to block below them. But I think it's easier to try to define a new kind of block or use samcarter solution with a thinner inner separation to compesate line width. – Ignasi Jun 11 '18 at 16:22
  • Hackish fix that works for your example at least: \newcommand{\titleblock}[1]{\useblockstyle{Justtitle}\block[bodyinnersep=-1cm]{#1}{}\useblockstyle{Default}} – Torbjørn T. Jun 12 '18 at 18:51
1

When tikzposter calculates the height of the body of a block, it does

\setlength{\TP@blockbodyheight}{\ht\TP@blockbodybox + \dp\TP@blockbodybox +2\TP@blockbodyinnersep}

As you can see two times the blockbodyinnersep is added to the height. You can make use of that fact and set the bodyinnersep in your \titleblock macro to an appropriate negative length:

\newcommand{\titleblock}[1]{\useblockstyle{Justtitle}\block[bodyinnersep=-4mm]{#1}{}\useblockstyle{Default}}

Complete example:

enter image description here

\documentclass{tikzposter}
\defineblockstyle{Justtitle}{
        }{
        \ifBlockHasTitle
                \draw[color=framecolor, fill=blocktitlebgcolor,
                rounded corners=\blockroundedcorners] (blocktitle.south west)
                rectangle (blocktitle.north east);
        \fi
}
\newcommand{\titleblock}[1]{\useblockstyle{Justtitle}\block[bodyinnersep=-4mm]{#1}{}\useblockstyle{Default}}

\begin{document}
\titleblock{Cool title}
\begin{columns}
        \column{0.5}
        \block{cool block title}{block text} 
        \block{next block}{more text}
        \column{0.5}
        \block{even cooler, but wrongly placed title}{Super cool text here}
        \block{hello}{duck}
\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.