tikzposter 中表格样式内块前不需要的垂直空间

tikzposter 中表格样式内块前不需要的垂直空间

我正在使用 tikzposter,发现表格样式的内部块有这种奇怪的行为。看起来内部块前的垂直空间是由标题的高度决定的,即使这种样式的标题出现在内部块内容的左侧。有人知道为什么会发生这种情况以及如何修复它吗?

\documentclass{tikzposter}

\useinnerblockstyle{Table}

\begin{document}

\block{}{

    If the inner block has no title, spacing is right:

    \innerblock{}{No unnecessary spacing above inner block.}

    If the inner block has a single line title, spacing is off by one line:

    \innerblock{Title}{Spacing above inner block off by one line.}

    If the innerblock has has a two-line title, spacing is off by two lines:

    \innerblock{Two-line\\Title}{Spacing above inner block off by two lines.
    \\
    \ldots}

    If the innerblock has has a five-line title, spacing is off by five lines:

    \innerblock{Five\\line\\Title\\\ldots\\\ldots}{Spacing above inner block off by five lines.
        \\
        \ldots\\
        \ldots\\
        \ldots\\
        \ldots}

}

\end{document}

在此处输入图片描述

答案1

发生这种情况的原因是标题的高度用于定位内容,而当标题位于正文旁边时,不需要额外的高度。在发布我最初的答案后,我意识到当\TP@innerblocktitleheight内部块有标题时,将长度设置为零会更容易,例如可以使用xpatch包及其来完成\xpatchcmd

在此处输入图片描述

\documentclass[a2paper]{tikzposter}

\usepackage{xpatch}
\makeatletter
\xpatchcmd
{\innerblock}% patch this
{\setlength{\TP@innerblocktitleheight}{\ht\TP@innerblocktitlebox + \dp\TP@innerblocktitlebox +2\TP@innerblocktitleinnersep}}% by replacing this
{\setlength{\TP@innerblocktitleheight}{0pt}}%with this
{}{}
\makeatother
\useinnerblockstyle{Table}


\begin{document}

\block{}{

    If the inner block has no title, spacing is right:

    \innerblock{}{No unnecessary spacing above inner block.}

    If the inner block has a single line title, spacing is off by one line:

    \innerblock{Title}{Spacing above inner block off by one line.}

    If the innerblock has has a two-line title, spacing is off by two lines:

    \innerblock{Two-line\\Title}{Spacing above inner block off by two lines.
    \\
    \ldots}

    If the innerblock has has a five-line title, spacing is off by five lines:

    \innerblock{Five\\line\\Title\\\ldots\\\ldots}{Spacing above inner block off by five lines.
        \\
        \ldots\\
        \ldots\\
        \ldots\\
        \ldots}

}
\end{document}

答案2

解决某些垂直间距问题的快速方法是\vspace{}。将间距插入{}(间距可以为负数)例如\vspace{-1mm}。您可以使用其他乳胶单位也一样。注意:如果过度使用可能会变得混乱,但它只是工具箱中的另一个方便工具。

相关内容