带有长表标题的对称 Tufte 书?

带有长表标题的对称 Tufte 书?

我使用 Pandoc 生成使用 longtable 的 LaTeX。默认情况下,longtable 的表格标题不会放置在边距中。根据此答案,可行的解决方案是以下 hack:

\makeatletter
\def\LT@makecaption#1#2#3{%
    \noalign{\smash{\hbox{\kern\textwidth\rlap{\kern\marginparsep
    \parbox[t]{\marginparwidth}{\vspace{10pt}%
\@tufte@caption@font\@tufte@caption@justification\noindent
    #1{#2:~}\ignorespaces#3}}}}}}
\makeatother

在 tufte-latex 文档中使用 longtable 在外边距中添加标题

但是,这总是将标题放在右侧。使用对称文档选项,边距会交替,因此会破坏边距放置。这是使用最新的 TinyTeX 和 XeTeX 引擎(尽管 PDFTeX 不会显示相同的错误)。

另一个小问题是,即使在具有右边距的页面上,标题也会在水平方向上略微缩进,并且行距似乎不正确?

字幕位置损坏: 字幕位置损坏


显示略微缩进的边距标题: 显示略微缩进的边距标题

M[非]WE:

\documentclass[symmetric,nobib]{tufte-book}

\usepackage{longtable,booktabs}

% fix longtable captions:
% https://tex.stackexchange.com/questions/182653/caption-in-the-outer-margin-using-longtable-within-a-tufte-latex-document
\makeatletter
\def\LT@makecaption#1#2#3{%
    \noalign{\smash{\hbox{\kern\textwidth\rlap{\kern\marginparsep
    \parbox[t]{\marginparwidth}{\vspace{10pt}%
\@tufte@caption@font\@tufte@caption@justification\noindent
    #1{#2:~}\ignorespaces#3}}}}}}
\makeatother

\begin{document}

\begin{table}[h]
    \centering
        \begin{tabular}{lcr}
            \toprule
            Heading & Style & Size \\
            \midrule
            Part & roman & {40} \\
            Chapter & italic & {40} \\
            Section & italic & {26} \\
            Subsection & italic & {26} \\
            Paragraph & italic & 10/14 \\
            \bottomrule
        \end{tabular}
    \caption{This is a table with a caption. This is some filler text.}
\end{table}

Here is some text.\marginnote{This is a marginnote.}

\begin{longtable}[]{@{}lll@{}}
    \caption{This is a longtable with a caption. This is some filler text.}\tabularnewline
    \toprule\noalign{}
    Sun & Earth & Moon \\
    \midrule\noalign{}
    \endfirsthead
    \toprule\noalign{}
    Sun & Earth & Moon \\
    \midrule\noalign{}
    \endhead
    \bottomrule\noalign{}
    \endlastfoot
    A & D & G \\
    B & E & H \\
    C & F & I \\
\end{longtable}

\newpage

\begin{table}[h]
\centering
    \begin{tabular}{lcr}
    \toprule
    Heading & Style & Size \\
    \midrule
    Part & roman & {40} \\
    Chapter & italic & {40} \\
    Section & italic & {26} \\
    Subsection & italic & {26} \\
    Paragraph & italic & 10/14 \\
    \bottomrule
    \end{tabular}
    \caption{This is a table with a caption. This is some filler text.}
\end{table}

Here is some text.\marginnote{This is a marginnote.}

\begin{longtable}[]{@{}lll@{}}
    \caption{This is a longtable with a caption. This is some filler text.}\tabularnewline
    \toprule\noalign{}
    Sun & Earth & Moon \\
    \midrule\noalign{}
    \endfirsthead
    \toprule\noalign{}
    Sun & Earth & Moon \\
    \midrule\noalign{}
    \endhead
    \bottomrule\noalign{}
    \endlastfoot
    A & D & G \\
    B & E & H \\
    C & F & I \\
\end{longtable}

\end{document}

答案1

这只是大卫的回答使其对称,因此如果您愿意,您需要对垂直定位进行相同的调整:

\documentclass[symmetric]{tufte-book}

\usepackage{booktabs}
\usepackage{longtable}

\makeatletter
\def\LT@makecaption#1#2#3{% ateb David Carlisle: https://tex.stackexchange.com/a/183344/ -> +symmetry: https://tex.stackexchange.com/a/701116/
  \ifodd\c@page 
    \noalign{%
      \smash{%
        \hbox{\kern\textwidth\kern-\parindent\rlap{\kern\marginparsep
            \parbox[t]{\marginparwidth}{%
              \@tufte@caption@font \@tufte@caption@justification \noindent 
              #1{#2: }\ignorespaces #3}}%
        }%
      }%
    }%
  \else
    \noalign{%
      \smash{%
        \hbox{\llap{%
            \parbox[t]{\marginparwidth}{%
              \@tufte@caption@font \@tufte@caption@justification \noindent 
              #1{#2: }\ignorespaces #3}%
            \kern\marginparsep
          }%
        }%
      }%
    }%  
  \fi
}
\makeatother

\begin{document}


\begin{table}[h]
  \centering
    \begin{tabular}{lcr}
      \toprule
      Heading & Style & Size \\
      \midrule
      Part & roman & {40} \\
      Chapter & italic & {40} \\
      Section & italic & {26} \\
      Subsection & italic & {26} \\
      Paragraph & italic & 10/14 \\
      \bottomrule
    \end{tabular}
 \caption{Heading styles used in.}
\end{table}




\begin{longtable}{lcccc}
\caption{Verification methods.}\\
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
\toprule
\endfirsthead
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
%\otoprule
\endhead
\bottomrule
\endfoot
One & * & & & \\
\midrule
Two & * & & & \\
\midrule
Three & * & & & \\
\midrule
Four & * & & & \\
\end{longtable}

\clearpage

\begin{longtable}{lcccc}
\caption{Verification methods.}\\
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
\toprule
\endfirsthead
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
%\otoprule
\endhead
\bottomrule
\endfoot
One & * & & & \\
\midrule
Two & * & & & \\
\midrule
Three & * & & & \\
\midrule
Four & * & & & \\
\end{longtable}

\end{document}

下面添加了一个框架来演示与页面布局的关系。这显示了更正后的水平对齐,但需要添加垂直调整,如 David 在其原始答案的评论中所述。

对称破解字幕

相关内容