![双列横向格式中图形定位不匹配](https://linux22.com/image/312337/%E5%8F%8C%E5%88%97%E6%A8%AA%E5%90%91%E6%A0%BC%E5%BC%8F%E4%B8%AD%E5%9B%BE%E5%BD%A2%E5%AE%9A%E4%BD%8D%E4%B8%8D%E5%8C%B9%E9%85%8D.png)
我正在尝试创建一个双列横向文档,每页有四幅图像(每列两幅,每页两列)。除了第一个图形外,所有图形的形式都相同。第一个图形包含有关其他图形的文本。由于某种原因,初始图形的独特性质使得第一列(第一页)的第二个图形出现在与所有剩余列中的第二个图形不同的垂直位置(位置不当的图形在页面上的位置低于其他图形)。我尝试过调整图形的定位行为,也尝试过调整声明双列横向格式的方式,但我所做的任何尝试都无法修复这个不良怪癖。例如,我尝试过
\documentclass[landscape,twocolumn,letterpaper]{article}
\usepackage{geometry}
和
\documentclass[landscape,twocolumn,letterpaper]{article}
\usepackage[lmargin=0.50in,rmargin=0.50in]{geometry} % b/c I need smaller margins
和
\documentclass{article}
\usepackage[landscape,twocolumn,lmargin=0.50in,rmargin=0.50in]{geometry}
那么,大家有什么解决办法吗?
\documentclass[landscape,twocolumn,letterpaper]{article}
\usepackage{geometry}
\usepackage{tikz}
\usepackage{lipsum}
% The basic figure I'm reusing
\DeclareRobustCommand{\myfig}[1]{
\begin{figure}[tb]
\centering
\textbf{Object \##1}\\
\vspace{10pt}
\begin{tikzpicture}[scale=0.6]
\draw[help lines] (0,0) grid (8,7);
\foreach \x in {0,...,7}
\foreach \y in {0,...,6}
\draw (\x+0.5, \y+0.5) node{0};
\end{tikzpicture}
\end{figure}
}
% ***************************** Main Matter *****************************
\begin{document}
\begin{figure}
\centering
\begin{minipage}[t]{4.0in}
\centering
\textbf{Title Line}\\
\lipsum[1]
\end{minipage}
\end{figure}
\myfig{1}
\myfig{2}
\myfig{3}
\clearpage
\myfig{4}
\myfig{5}
\myfig{6}
\myfig{7}
\end{document}
答案1
我使用 flowfram 将页面分成 4 个象限,每个图形都位于每个象限的中心(垂直和水平)。
\documentclass[landscape,twocolumn,letterpaper]{article}
\usepackage{geometry}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{flowfram}
\newflowframe[1,2]{\dimexpr 0.5\textwidth - 0.5\columnsep}{\dimexpr 0.5\textheight - 0.5\columnsep}%
{0pt}{\dimexpr 0.5\textheight + 0.5\columnsep}[main]
\newflowframe[1,2]{\dimexpr 0.5\textwidth - 0.5\columnsep}{\dimexpr 0.5\textheight - 0.5\columnsep}%
{0pt}{0pt}[lowerleft]
\newflowframe[1,2]{\dimexpr 0.5\textwidth - 0.5\columnsep}{\dimexpr 0.5\textheight - 0.5\columnsep}%
{\dimexpr 0.5\textwidth + 0.5\columnsep}{\dimexpr 0.5\textheight + 0.5\columnsep}[upperright]
\newflowframe[1,2]{\dimexpr 0.5\textwidth - 0.5\columnsep}{\dimexpr 0.5\textheight - 0.5\columnsep}%
{\dimexpr 0.5\textwidth + 0.5\columnsep}{0pt}[lowerright]
% The basic figure I'm reusing
\DeclareRobustCommand{\myfig}[1]{
\begin{figure}[p]
\centering
\textbf{Object \##1}\\
\vspace{10pt}
\begin{tikzpicture}[scale=0.6]
\draw[help lines] (0,0) grid (8,7);
\foreach \x in {0,...,7}
\foreach \y in {0,...,6}
\draw (\x+0.5, \y+0.5) node{0};
\end{tikzpicture}
\end{figure}
}
% ***************************** Main Matter *****************************
\begin{document}
\centering
\begin{figure}[p]
\centering
\textbf{Title Line}\\
\lipsum[1]
\end{figure}
\myfig{1}
\myfig{2}
\myfig{3}
\myfig{4}
\myfig{5}
\myfig{6}
\myfig{7}
\end{document}
答案2
如果你想要绝对定位,那么我的建议是使用类似的东西来定位内容eso-pic
。我已完成如下操作:
\documentclass[landscape,letterpaper]{article}
\usepackage{eso-pic,adjustbox,tikz,lipsum}
\pagestyle{empty}% No header/footer
% The basic figure I'm reusing
\DeclareRobustCommand{\myfig}[1]{%
\begin{tabular}{c}
\textbf{Object \##1} \\[\normalbaselineskip]
\begin{tikzpicture}[scale=0.6]
\draw[help lines] (0,0) grid (8,7);
\foreach \x in {0,...,7}
\foreach \y in {0,...,6}
\draw (\x+0.5, \y+0.5) node{0};
\end{tikzpicture}
\end{tabular}%
}
% ***************************** Main Matter *****************************
\begin{document}
\mbox{}% Just put something on the page
\AddToShipoutPictureFG*{% Place on _this_ page's ForeGround
% Top left
\put(\LenToUnit{\dimexpr.3333\paperwidth-2in},\LenToUnit{.6667\paperheight}){%
\begin{minipage}{4in}
\centering\textbf{Title line} \par\medskip
\lipsum[1]
\end{minipage}}%
% Bottom left
\put(\LenToUnit{.3333\paperwidth},\LenToUnit{.3333\paperheight}){%
\adjustbox{center=0pt}{\myfig{1}}}
% Top right
\put(\LenToUnit{.6667\paperwidth},\LenToUnit{.6667\paperheight}){%
\adjustbox{center=0pt}{\myfig{2}}}
% Bottom right
\put(\LenToUnit{.6667\paperwidth},\LenToUnit{.3333\paperheight}){%
\adjustbox{center=0pt}{\myfig{3}}}
}
\clearpage
\mbox{}% Just put something on the page
\AddToShipoutPictureFG*{% Place on _this_ page's ForeGround
% Top left
\put(\LenToUnit{.3333\paperwidth},\LenToUnit{.6667\paperheight}){%
\adjustbox{center=0pt}{\myfig{4}}}
% Bottom left
\put(\LenToUnit{.3333\paperwidth},\LenToUnit{.3333\paperheight}){%
\adjustbox{center=0pt}{\myfig{5}}}
% Top right
\put(\LenToUnit{.6667\paperwidth},\LenToUnit{.6667\paperheight}){%
\adjustbox{center=0pt}{\myfig{6}}}
% Bottom right
\put(\LenToUnit{.6667\paperwidth},\LenToUnit{.3333\paperheight}){%
\adjustbox{center=0pt}{\myfig{7}}}
}
\end{document}
minipage
s和 tabular
垂直居中(除非您指定其他内容)。内容的水平居中来自adjustbox
的center=0pt
选项(您也可以使用常规的\makebox[0pt]
),再加上由于已知文本框的宽度而进行的一些固定宽度调整。