![浮动和标题边距混乱](https://linux22.com/image/266119/%E6%B5%AE%E5%8A%A8%E5%92%8C%E6%A0%87%E9%A2%98%E8%BE%B9%E8%B7%9D%E6%B7%B7%E4%B9%B1.png)
我无法让宽浮动的标题正确左对齐。我有对开页,经过多次试验,我最接近成功的是只对奇数页进行正确的布局。
我希望宽图和标题在页面上都左对齐。我希望标题比浮动图宽得多。
这是我的 MWE:
\documentclass[openright,twoside]{book}
\usepackage[facing=yes]{floatrow}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{tabulary}
%%
% Set page layout geometry
% The asymmetric option keeps the margin notes always on the same side of the page which is the way Tufte does it.
\RequirePackage[
letterpaper,
asymmetric,
includemp,
inner=0.5in,
bindingoffset=1.0in,
width=6.75in,
marginparsep=0.25in,
marginparwidth=2in,
showframe,
] {geometry}
\floatsetup[widefloat]
{
floatwidth=6.75in,
objectset=raggedright,
}
%
\captionsetup[widefloat]
{
margin={0pt,2.25in},
justification=justified,
font=small
}
\begin{document}
\lipsum[2]
\begin{table*}[ht]
\begin{tabulary}{\linewidth}{|L|l|l|l|l|l|l|}
\hline
foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo \\
\hline
\end{tabulary}
\caption{Pellentesque habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas. Donec odio elit, dictum in, hendrerit sit amet,
egestas sed, leo. Praesent feugiat sapien aliquet odio. Integer vitae justo.}
\end{table*}
\clearpage
\lipsum[2]
\begin{table*}[ht]
\begin{tabulary}{\linewidth}{|L|l|l|l|l|l|l|}
\hline
foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo \\
\hline
\end{tabulary}
\caption{Pellentesque habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas. Donec odio elit, dictum in, hendrerit sit amet,
egestas sed, leo. Praesent feugiat sapien aliquet odio. Integer vitae justo.}
\end{table*}
\end{document}
这是我遇到的麻烦(showframe
处于打开状态)。请注意,宽表格正确地向左对齐,但标题却挂在了错误的一侧。
- - - 编辑 - - -
据我所知,floatrow
左右边距有错误。此 hack 使用changepage
撤消边距混合的包:
\newcommand{\widecapfix}
{
\checkoddpage
\ifoddpage
\captionsetup{margin={0in,2.25in}}
\else
\captionsetup{margin={2.25in,0in}}
\fi
}
所以,我必须\widecapfix
在标题上方插入每个宽图用法。我觉得这太恶心了。
答案1
如果您愿意将表格从环境转换为命令结构,我修改了一个boxhandler
包例程以实现您想要的结果。我必须对命令进行\ReciteTable
双重更改:我必须将表格标题放在表格内容之后,而不是之前;我必须强制将标题相对于超大表格左对齐。
\documentclass[openright,twoside]{book}
\usepackage{lipsum}
\usepackage{tabulary}
\usepackage{boxhandler}
%%
% Set page layout geometry
% The asymmetric option keeps the margin notes always on the same side of the page which is the way Tufte does it.
\RequirePackage[
letterpaper,
asymmetric,
includemp,
inner=0.5in,
bindingoffset=1.0in,
width=6.75in,
marginparsep=0.25in,
marginparwidth=2in,
showframe,
] {geometry}
\makeatletter
\renewcommand\ReciteTable[6][ht]{%
\begin{table}[#1]%
\begin{\LRTablePlacement}%
\let\@makecaption\new@makecaption%
\setlength\abovecaptionskip{\arabic{abovecaptionskipterm}\p@}%
\setlength\belowcaptionskip{\arabic{belowcaptionskipterm}\p@}%
\set@DataBoxWidth{#3}%
\setlength\CaptionBoxWidth{#4}%
\set@BoxOffsets%
\if T#6%
\rule{\@DataBoxOffset}{0in}%
\makebox[\@DataBoxWidth][l]{#5}%
\rule{\@DataBoxOffset}{0in}\\%
\fi
\rule{\@DataBoxOffset}{0in}%
\usebox{#3}%
\rule{\@DataBoxOffset}{0in}\\%
\par%
\parbox{\CaptionBoxWidth}{\bx@caption{#2}}%
\rule{\@CaptionBoxOffset}{0em}%
\rule{\@CaptionBoxOffset}{0em}%
\if T#6%
\rule{\@DataBoxOffset}{0in}\\%
\makebox[\@DataBoxWidth][r]{#5}%
\rule{\@DataBoxOffset}{0in}%
\fi
\let\@makecaption\old@makecaption%
\setlength\abovecaptionskip \oldabovecaptionskip%
\setlength\belowcaptionskip \oldbelowcaptionskip%
\end{\LRTablePlacement}%
\end{table}%
}
\makeatother
\begin{document}
\lipsum[2]
\constrainCaptionWidth{\textwidth}
\captionStyle{n}{l}
\setlength\TableDeadMargin{0em}
\bxtable[ht]{Pellentesque habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas. Donec odio elit, dictum in, hendrerit sit amet,
egestas sed, leo. Praesent feugiat sapien aliquet odio. Integer vitae justo.}
{%
\normalsize
\begin{tabulary}{6.75in}{|L|l|l|l|l|l|l|}
\hline
foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo \\
\hline
\end{tabulary}
}
\clearpage
\lipsum[2]
\bxtable[ht]{Pellentesque habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas. Donec odio elit, dictum in, hendrerit sit amet,
egestas sed, leo. Praesent feugiat sapien aliquet odio. Integer vitae justo.}
{%
\normalsize
\begin{tabulary}{6.75in}{|L|l|l|l|l|l|l|}
\hline
foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo & barbarbar & foofoofoo \\
\hline
\end{tabulary}
}
\end{document}