如何在 baposter 中将框标题文本居中

如何在 baposter 中将框标题文本居中

我正在使用 baposter 类编写海报。我想将文本置于标题框的中心(针对某个特定的标题框,而不是全部)。以下是最小工作示例。

\documentclass[pdftex, british,a0paper, fontscale=.32]{baposter}
\usepackage{titling}
\usepackage{enumitem}
\usepackage{color}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{graphicx}
\title{My Poster}
\author{Apurba Paul}
\begin{document}
\begin{poster}{
{}
{\thetitle}
{theauthor}
{}}
\headerbox{Box title}{name=box1, column=0, row=0}{%
content here
}
\end{document}

我希望“框标题”出现在框标题的中心而不是左侧。

答案1

所有样式都有其硬编码的锚点,因此您应该选择headershape=small-roundedheadershape=roundedright根据 baposter_guide.pdf给出的居中框标题进行选择。

如果您想使用其他样式,则必须更改其定义。为此,您可以查看baposter.cls框标题的定义,并根据需要进行更改。

例如,smallrounded定义如下(baposter.cls 中的 685-688 行):

\newcommand{\baposter@box@headerdrawtext@smallrounded}[1]{
  \path (\baposter@box@name nw) +(0.5\boxwidth,-0.5\baposter@box@@boxheaderheight) node[anchor=center] {#1};%
}

rectangle风格是(第 682-684 行)

\newcommand{\baposter@box@headerdrawtext@rectangle}[1]{
  \path (\baposter@box@name nw) +(0em,-0.5\baposter@box@@boxheaderheight) node[anchor=west,inner sep=0.4em] {#1};%
}

(\baposter@box@name nw) +(0em,-0.5\baposter@box@@boxheaderheight)如您所见,第二种样式将标题锚定在标题框的左侧和西北角与西南角之间的中点。而smallrounded样式将标题锚定在标题框的中心和中心点。如果您可以使用rectangle样式获得第二种效果,请在序言中使用以下代码更改其定义

\makeatletter
\renewcommand{\baposter@box@headerdrawtext@rectangle}[1]{
  \path (\baposter@box@name nw) +(0.5\boxwidth,-0.5\baposter@box@@boxheaderheight) node[anchor=center] {#1};%
}
\makeatother

并将获得一个rectangle带有居中文本的标题:

\documentclass[pdftex, british, a0paper, fontscale=.32]{baposter}

\usepackage{titling}
\title{My Poster}
\author{Apurba Paul}

\makeatletter
\renewcommand{\baposter@box@headerdrawtext@rectangle}[1]{
  \path (\baposter@box@name nw) +(0.5\boxwidth,-0.5\baposter@box@@boxheaderheight) node[anchor=center] {#1};%
}
\makeatother

\begin{document}
\begin{poster}{%
  background=none,
%  bgColorOne=gray!30,
  headerColorOne=blue!30,
  headershade=plain,
  boxshade=none,
  headershape=rectangle,
}
{}
{\thetitle}
{\theauthor}
{}

\headerbox{Box title}{name=box1, column=0, row=0}{content here}
\end{poster}
\end{document}

在此处输入图片描述

相关内容