The line spacing in blocks of the tikzposter seem to depend on the number of paragraphs or the presence of images included by the use \includegraphics
.
For example in the poster example distributed with the tikzposter package, the line spacing is different in two paragraphs of the right block titled "Columns". How could I define a uniform line spacing in all the poster blocks including the title?
[Tex/LaTex] line spacing in tikzposter
line-spacingtikz-pgftikzposter
Related Solutions
I ended up solving it myself. Below is the code I used; if you put it in myposter.sty
then use \usepackage[colalign]{myposter}
to enable the alignment.
It works by saving the natural heights of all columns into the aux file, along with how many blocks there are. Then next compilation, for each column, it looks at the difference between the stored height and the maximum stored height, divides that by the number of blocks, and adds that much padding inside each block (at the top and bottom.)
\usepackage{letltxmacro}
\usepackage{ifthen}
\newif\ifmy@colalign
\my@colalignfalse
\DeclareOption{colalign}{
\my@colaligntrue
}
\ProcessOptions\relax
\ifmy@colalign
% Align the bottoms of columns
% Declarations
\newcounter{my@column}
\newcounter{my@column@loop}
\newcounter{my@block}
\newdimen\my@columnextraspace
\newdimen\my@maxcolheight
\newdimen\my@colheight
\newdimen\my@blocktopstart
\newdimen\my@rounded
% Store the natural height and number of blocks of the current column in the aux file
\gdef\my@storecolheight{
\ifnum\value{my@column} > 0 %
\expandafter\newdimen\csname my@colheight\alph{my@column}\endcsname
\expandafter\setlength\csname my@colheight\alph{my@column}\endcsname{\my@colheight}
\immediate\write\@auxout{\noexpand\newlabel{my@colheight\alph{my@column}}{{\the\my@colheight}{}}}
\immediate\write\@auxout{\noexpand\newlabel{my@numblocks\alph{my@column}}{{\the\c@my@block}}}
\fi
}
\LetLtxMacro{\orig@block}{\block}
% Replace the \block command with a version that pads each block by \my@columnextraspace
\renewcommand{\block}[3][]{%
\ifTP@columnEnvironment
\my@blocktopstart=0pt\relax
\advance\my@blocktopstart-\TP@blocktop
\fi
\orig@block[{#1}]{#2}{\vspace*{-0.5\my@columnextraspace}#3\vspace*{-0.5\my@columnextraspace}}
\ifTP@columnEnvironment
% count number of blocks
\stepcounter{my@block}
% keep track of the height of the current column
\advance\my@blocktopstart\TP@blocktop
\advance\my@colheight\my@blocktopstart
% don't add the padding to the height
\advance\my@colheight-\my@columnextraspace
\fi
}
% Store the maximum natural height of any column in the aux file
\gdef\my@storemaxcolheight{
\ifnum\value{my@column} > 0 %
\newdimen\my@maxcolheight
\newdimen\my@colheight@loop
\setcounter{my@column@loop}{0}
\loop\ifnum\value{my@column@loop}<\value{my@column}
\stepcounter{my@column@loop}
\my@colheight@loop\csname my@colheight\alph{my@column@loop}\endcsname
\ifnum\my@colheight@loop<\my@maxcolheight
\my@maxcolheight\my@colheight@loop
\fi
\repeat
\immediate\write\@auxout{\noexpand\newlabel{my@maxcolheight}{{\the\my@maxcolheight}{}}}
\fi
}
% Read the column height information and calculate how much extra space the current column needs per block
\gdef\my@calcextraspace{
\@ifundefined{r@my@maxcolheight}{%
\my@columnextraspace=0pt\relax
}{%
\expandafter\my@maxcolheight\ref{my@maxcolheight}
\expandafter\my@colheight\ref{my@colheight\alph{my@column}}
\setcounter{my@block}{\ref{my@numblocks\alph{my@column}}}
\my@columnextraspace\my@maxcolheight
\advance\my@columnextraspace-\my@colheight
\divide\my@columnextraspace by \value{my@block}
}
}
% Replace \column command by a version which stores the height (of the previous column) and calls \my@calcextraspace
\gdef\column#1{ % #1: relative width
\ifTP@columnEnvironment
\my@storecolheight
\stepcounter{my@column}
\my@calcextraspace
\setcounter{my@block}{0}
\my@blocktopstart0pt
\my@colheight0pt
% Now the normal \column command
\normalsize
\setlength{\TP@blocktop}{\TP@coltop}
\setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\TP@colspace}
\setlength{\colwidth}{#1\TP@visibletextwidth+#1\TP@colspace-\TP@colspace-\blocklinewidth}
\setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\blocklinewidth}
\fi
}
% Replace the columns environment with a version which stores the height of the final column and the max column
\renewenvironment{columns}{
\TP@columnEnvironmenttrue
\setlength{\TP@colcenter}{-0.5\TP@visibletextwidth-\TP@colspace-0.5\blocklinewidth}
\global\TP@colcenter=\TP@colcenter
\global\TP@coltop=\TP@blocktop
\global\TP@colbottom=\TP@blocktop
\colwidth=0pt
}{
\my@storecolheight
\my@storemaxcolheight
\TP@columnEnvironmentfalse
\global\TP@blocktop=\TP@colbottom
}
\fi
You can always use a minipage
:
\documentclass[25pt, a0paper, portrait, margin=0mm, innermargin=15mm, blockverticalspace=15mm, colspace=15mm, subcolspace=8mm]{tikzposter}
\usepackage{xcolor}
\usepackage{filecontents}% http://ctan.org/pkg/filecontents
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{tikz}
\usepackage{adjustbox}
\begin{filecontents*}{myDummyPictureCode.tex}
\begin{tikzfigure}[Some nice caption for the figure]
\centering
\begin{tikzpicture}
\draw [color=red] (0,0) rectangle (20,10) node [midway] {\huge myFigure};
\end{tikzpicture}
\end{tikzfigure}
\end{filecontents*}
\title{Title}
\author{Name}
\usetheme{Autumn}\usecolorstyle[colorPalette=BrownBlueOrange]{Germany}
\begin{document}
\maketitle
\begin{columns}
\column{0.7} \block{FigureOutside Block}{
\lipsum[1]
}
\column{0.3} \block{}{
\input{./myDummyPictureCode.tex}
}
\end{columns}
% Text and figure Inside the Block
\block{Text and figure Block}{
\begin{minipage}[t]{0.7\linewidth}
\lipsum[1]
\end{minipage}%
\begin{adjustbox}{valign=t}
\begin{minipage}[t]{0.3\linewidth}
\input{./myDummyPictureCode.tex}
\end{minipage}
\end{adjustbox}
}
\end{document}
Best Answer
Actually you could just have posted the first two words of the title and not bothered with the example:-)
Bad linespacing in TeX is almost always due to changing the font size but not including the end of paragraph in the same scope, which results in the new size text being set to the original baseline.
In the cited example you need
Probably the definition of
\block
ought to provide an implicit end of paragraph, but clearly it doesn't so you need to add it explictly.