我注意到,所有包含\includegraphics
语句的 tikzfigures(在 tikzposter 类中定义)都偏离了中心。如下面的第二个内部块所示(请原谅图片,graphicx
演示选项在 tikzposter 下不起作用),图片在块内自动垂直居中(请注意顶部的较大空间)。无论我使用哪种块样式,都会发生这种情况。有人知道如何正确地垂直居中吗?(重新定义tikzfigure
为垂直居中其内容会起作用,但仍然看起来很奇怪)
此外,在我的实际项目中,我使用了一个multicols
包含不同大小图形的两列环境(参见第三个内块)。较大的图片在水平方向上略微偏离中心(这在我的实际项目中更为明显)。此外,较小的图片似乎总是位于顶部,而不是中心。我尝试了各种multicol
相关选项来解决这个问题,但似乎都没有用。我不确定我的多列问题是否与我之前的问题有关,但希望是的。
梅威瑟:
\documentclass[25pt, a0paper, portrait, margin=0pt, innermargin=5pt, colspace=45pt, blockverticalspace=5pt]{tikzposter}
% dummy text generation
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{xpatch}
\usepackage{todonotes}
\usepackage{multicol}
% remove space that empty innerblock title leaves behind
% see https://tex.stackexchange.com/questions/447378/tikzposter-leaves-a-gap-in-empty-innerblock-title
\makeatletter
\xpatchcmd{\innerblock}{\node[minimum width=\TP@innerblocktitlewidth, minimum height=\TP@innerblocktitleheight, anchor=center] (innerblocktitle)}{\node[inner sep=0pt, minimum width=\TP@innerblocktitlewidth, minimum height=\TP@innerblocktitleheight, anchor=center] (innerblocktitle)}{}{}
\makeatother
\defineinnerblockstyle{myinner}{
titlewidthscale=1, bodywidthscale=1, titlecenter,
titleoffsetx=0pt, titleoffsety=0pt, bodyoffsetx=0pt, bodyoffsety=0pt,
bodyverticalshift=0pt, roundedcorners=0, linewidth=0.0cm,
titleinnersep=0pt, bodyinnersep=20pt
}{
\filldraw[innerblockbodybgcolor]
(innerblockbody.south west) rectangle (innerblockbody.north east);
\draw [line width=0.5cm,blue] (innerblockbody.south) -- (innerblockbody.north);
}
\usetheme{Simple}
\usebackgroundstyle{Empty}
\useblockstyle{Basic}
\useinnerblockstyle{myinner}
\title{Test Test Test}
\author{Myself}
\date{\today}
\institute{University of Foobar}
\begin{document}
\maketitle
\setlength\columnseprule{0.32cm}
\colorlet{blockbodybgcolor}{blue}
\block{Blocktiltle}{
\colorlet{innerblockbodybgcolor}{white}
\innerblock{}{\lipsum[1]}
\colorlet{innerblockbodybgcolor}{gray}
\innerblock{}{
\centering
\begin{minipage}{0.9\linewidth}
\centering
\begin{tikzfigure}
\includegraphics[width=1.0\linewidth]{example-image-duck}
\end{tikzfigure}
\end{minipage}\hfill}
\colorlet{innerblockbodybgcolor}{red}
\innerblock{}{
\centering
\begin{minipage}{0.49\linewidth}
\centering
\begin{tikzfigure}
\includegraphics[width=0.49\textwidth]{example-image-duck}
\end{tikzfigure}
\end{minipage}\hfill
\begin{minipage}{0.49\linewidth}
\begin{tikzfigure}
\includegraphics[width=0.495\textwidth]{example-image-duck}
\includegraphics[width=0.495\textwidth]{example-image-duck}
\end{tikzfigure}
\end{minipage}
}
}
\end{document}
答案1
欢迎来到 TeX.SE!根据这个很好的答案,最有效的方法可能是使用 minipages 这个非常古老的方法。
\documentclass[25pt, a0paper, portrait, margin=0pt, innermargin=40pt, colspace=45pt, blockverticalspace=45pt]{tikzposter}
% dummy text generation
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{xpatch}
\usepackage{todonotes}
\usepackage{multicol}
% remove space that empty innerblock title leaves behind
% see https://tex.stackexchange.com/questions/447378/tikzposter-leaves-a-gap-in-empty-innerblock-title
\makeatletter
\xpatchcmd{\innerblock}{\node[minimum width=\TP@innerblocktitlewidth, minimum height=\TP@innerblocktitleheight, anchor=center] (innerblocktitle)}{\node[inner sep=0pt, minimum width=\TP@innerblocktitlewidth, minimum height=\TP@innerblocktitleheight, anchor=center] (innerblocktitle)}{}{}
\makeatother
\defineinnerblockstyle{myinner}{
titlewidthscale=1, bodywidthscale=1, titlecenter,
titleoffsetx=0pt, titleoffsety=0pt, bodyoffsetx=0pt, bodyoffsety=0pt,
bodyverticalshift=0pt, roundedcorners=0, linewidth=0.0cm,
titleinnersep=0pt, bodyinnersep=20pt
}{
\filldraw[innerblockbodybgcolor]
(innerblockbody.south west) rectangle (innerblockbody.north east);
}
\usetheme{Simple}
\usebackgroundstyle{Empty}
\useblockstyle{Basic}
\useinnerblockstyle{myinner}
\title{Test Test Test}
\author{Myself}
\date{\today}
\institute{University of Foobar}
\begin{document}
\maketitle
\setlength\columnseprule{0.32cm}
\colorlet{blockbodybgcolor}{blue}
\block{Blocktiltle}{
\colorlet{innerblockbodybgcolor}{white}
\innerblock{}{\lipsum[1]}
\colorlet{innerblockbodybgcolor}{gray}
\innerblock{}{
\begin{tikzfigure}
\includegraphics[width=0.22\linewidth]{example-image-duck}
\end{tikzfigure}}
\colorlet{innerblockbodybgcolor}{red}
\innerblock{}{
\centering% https://tex.stackexchange.com/a/263807/121799
\begin{minipage}[c]{0.45\linewidth}
\begin{tikzfigure}[Caption of figure1]
\centering
\includegraphics[width=0.21\linewidth]{example-image-a}
\end{tikzfigure}%
\end{minipage}\hfill
\begin{minipage}[c]{0.45\linewidth}
\begin{tikzfigure}[Caption of figure2]
\centering
\includegraphics[width=0.45\linewidth]{example-image-b}
\end{tikzfigure}%
\end{minipage}%
}
}
\end{document}
答案2
不是一个答案,而是在土拨鼠答案似乎是example-image-a
稍微在左边, 稍微example-image-b
在右边。
\documentclass[25pt, a0paper, portrait, margin=0pt, innermargin=40pt, colspace=45pt, blockverticalspace=45pt]{tikzposter}
% dummy text generation
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{xpatch}
\usepackage{todonotes}
\usepackage{multicol}
% remove space that empty innerblock title leaves behind
% see https://tex.stackexchange.com/questions/447378/tikzposter-leaves-a-gap-in-empty-innerblock-title
\makeatletter
\xpatchcmd{\innerblock}{\node[minimum width=\TP@innerblocktitlewidth, minimum height=\TP@innerblocktitleheight, anchor=center] (innerblocktitle)}{\node[inner sep=0pt, minimum width=\TP@innerblocktitlewidth, minimum height=\TP@innerblocktitleheight, anchor=center] (innerblocktitle)}{}{}
\makeatother
\defineinnerblockstyle{myinner}{
titlewidthscale=1, bodywidthscale=1, titlecenter,
titleoffsetx=0pt, titleoffsety=0pt, bodyoffsetx=0pt, bodyoffsety=0pt,
bodyverticalshift=0pt, roundedcorners=0, linewidth=0.0cm,
titleinnersep=0pt, bodyinnersep=20pt
}{
\filldraw[innerblockbodybgcolor]
(innerblockbody.south west) rectangle (innerblockbody.north east);
}
%%very usefull test grid%%
\newcommand{\myGrid}{%
\begin{tikzpicture}[
overlay,
remember picture,
shift={(current page.north west)}
]
\draw[very thin, blue!10, xstep=\paperwidth/50, ystep=\paperheight/50]
(current page.south west) grid (current page.north east);
\draw[very thin, green!50!black, xstep=\paperwidth/10, ystep=\paperheight/5]
(current page.south west) grid (current page.north east);
\end{tikzpicture}%
}
%%%%%%%
\usetheme{Simple}
\usebackgroundstyle{Empty}
\useblockstyle{Basic}
\useinnerblockstyle{myinner}
\title{Test Test Test}
\author{Myself}
\date{\today}
\institute{University of Foobar}
\begin{document}
\maketitle
\setlength\columnseprule{0.32cm}
\colorlet{blockbodybgcolor}{blue}
\block{Blocktiltle}{
\colorlet{innerblockbodybgcolor}{white}
\innerblock{}{\lipsum[1]}
\colorlet{innerblockbodybgcolor}{gray}
\innerblock{}{
\begin{tikzfigure}
\includegraphics[width=0.22\linewidth]{example-image-c}
\end{tikzfigure}}
\colorlet{innerblockbodybgcolor}{red}
\innerblock{}{
\centering% https://tex.stackexchange.com/a/263807/121799
\begin{minipage}[c]{0.45\linewidth}
\begin{tikzfigure}[Caption of figure1]
\centering
\includegraphics[width=0.21\linewidth]{example-image-a}
\end{tikzfigure}%
\end{minipage}\hfill
\begin{minipage}[c]{0.45\linewidth}
\begin{tikzfigure}[Caption of figure2]
\centering
\includegraphics[width=0.45\linewidth]{example-image-b}
\end{tikzfigure}%
\end{minipage}%
\myGrid%
}
}
\end{document}