如何headerbox
使用自定义标题的对齐方式(在我的情况下是居中对齐) baposter
?
尝试这个:
\begin{poster}{headerfont=\Large\sf\centering}
或者
\headerbox{\rule{0pt}{0pt}\hspace{\stretch{1}} Motivation \hspace{\stretch1}\rule{0pt}{0pt}}
{name=motivation}
{foo bar}
根本不起作用。
使用时\hspace{1cm}
空间适当宽阔。
编辑:
\documentclass[a0paper,portrait,fontscale=.298]{baposter}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[%font=small,
labelfont=sf]{caption} % Required for specifying captions to tables and figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{relsize} % Used for making text smaller in some places
\usepackage{amsmath,amssymb}
\usepackage{multicol}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\definecolor{bordercol}{RGB}{40,40,40} % Border color of content boxes
\definecolor{headercol1}{RGB}{224,177,0} % Background color for the header in the content boxes (left side)
\definecolor{headercol2}{RGB}{80,80,80} % Background color for the header in the content boxes (right side)
\definecolor{headerfontcol}{RGB}{0,0,0} % Text color for the header text in the content boxes
\definecolor{boxcolor}{RGB}{255,255,255} % Background color for the content in the content boxes
\begin{document}
\begin{poster}{
borderColor=bordercol, % Border color of content boxes
headerColorOne=headercol1, % Background color for the header in the content boxes (left side)
headerColorTwo=headercol1, % Background color for the header in the content boxes (right side)
headerFontColor=headerfontcol, % Text color for the header text in the content boxes
boxColorOne=boxcolor, % Background color for the content in the content boxes
headershape=rectangle, % Specify the rounded corner in the content box headers
headerfont=\Large\sf, % Font modifiers for the text in the content box headers
textborder=%rectangle,%
faded,
linewidth=1pt,
background=none,
colspacing=5pt,
columns=6,
headerborder=open, % Change to closed for a line under the content box headers
boxshade=plain,
headerheight=.095\textheight
}
%----------------------------------------------------------------------------------------
% TITLE AND AUTHOR NAME
%------------------------------------------------------------------------------------ ----
{} % University/lab logo
{Title} % Poster title
{Tomas Marny\\ % Author names
{tom@smarny}} % Author email addresses
{} % University/lab logo
\headerbox{\rule{0pt}{0pt}\hspace{\stretch{4}} Motivation} \hspace{\stretch{4}}\rule{0pt}{0pt}
{name=motivation,column=0,row=0,span=6}
{foo bar}
\end{poster}
\end{document}
答案1
查看baposter.cls
文件中的 (line 678--) 部分header text drawing
,你会发现 中图块的对齐方式headerbox
由 决定 headershape=rectangle, roundedleft, rounderright, rounded, smallrounded
。只有最后两个形状的文本居中对齐。因此,最简单的方法是使用rounded
或smallrounded
选项,它们会给出圆角和居中标题。如果 OP 想要保留具有尖角的矩形形状,则etoolbox
可以通过以下方法提供帮助patchcmd
(抱歉,图片无法上传,稍后再试)
%\patchcmd{<command>}{<code to replace>}{<code>}{<success>}{<failure>}
\makeatletter
\patchcmd{\baposter@box@headerdrawtext@rectangle}{0em}{0.5\boxwidth}{}{}
\patchcmd{\baposter@box@headerdrawtext@rectangle}{west}{center}{}{}
\makeatother
代码
\documentclass[a4paper,portrait,fontscale=.298]{baposter}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[%font=small,
labelfont=sf]{caption} % Required for specifying captions to tables and figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{relsize} % Used for making text smaller in some places
\usepackage{amsmath,amssymb}
\usepackage{multicol}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{etoolbox}
\definecolor{bordercol}{RGB}{40,40,40} % Border color of content boxes
\definecolor{headercol1}{RGB}{224,177,0} % Background color for the header in the content boxes (left side)
\definecolor{headercol2}{RGB}{80,80,80} % Background color for the header in the content boxes (right side)
\definecolor{headerfontcol}{RGB}{0,0,0} % Text color for the header text in the content boxes
\definecolor{boxcolor}{RGB}{255,255,255} % Background color for the content in the content boxes
\begin{document}
\begin{poster}{%headerfont=\Large\sf\centering,
borderColor=bordercol, % Border color of content boxes
headerColorOne=headercol1, % Background color for the header in the content boxes (left side)
headerColorTwo=headercol1, % Background color for the header in the content boxes (right side)
headerFontColor=headerfontcol, % Text color for the header text in the content boxes
boxColorOne=boxcolor, % Background color for the content in the content boxes
headershape=rectangle, % Specify the rounded corner in the content box headers
headerfont=\Large\sf, % Font modifiers for the text in the content box headers
textborder=%rectangle,%
faded,
linewidth=1pt,
background=none,
colspacing=5pt,
columns=6,
headerborder=open, % Change to closed for a line under the content box headers
boxshade=plain,
headerheight=.095\textheight
}
%----------------------------------------------------------------------------------------
% TITLE AND AUTHOR NAME
%------------------------------------------------------------------------------------ ----
{} % University/lab logo
{Title} % Poster title
{Tomas Marny\\ % Author names
{tom@smarny}} % Author email addresses
{} % University/lab logo
%---- start from default
\headerbox{Motivation1}
{name=motivation1,column=0,row=0,span=6}
{Left aligned}
%---- local change via etoolbox
\bgroup
%\patchcmd{<command>}{<code to replace>}{<code>}{<success>}{<failure>}
\makeatletter
\patchcmd{\baposter@box@headerdrawtext@rectangle}{0em}{0.5\boxwidth}{}{}
\patchcmd{\baposter@box@headerdrawtext@rectangle}{west}{center}{}{}
\makeatother
\headerbox{Motivation2}
{name=motivation2,column=0,row=0,span=6,below = motivation1}
{Center aligned}
\egroup
%---- Back to default value
\headerbox{Motivation3}
{name=motivation3,column=0,row=0,span=6,below = motivation2}
{Left aligned}
\end{poster}
\end{document}