并排放置时标题和表格未对齐

并排放置时标题和表格未对齐

我想将表格的标题放在其左侧,因此我尝试采用建议的方法在这个答案中。正如那里唯一的评论所指出的那样,我也遇到了错位问题。评论说,\mbox{}\\[-\baselineskip]在每个小页面内立即添加可以解决问题,因为它会产生一条虚拟线,对齐可以从中挂起。

这正是我的 .tex 文件中的内容:

\begin{table}[!t]
\begin{minipage}[t]{0.25\textwidth}
  %\mbox{}\\[-\baselineskip]
  \caption{The two ``super''-relations and their constituent fine-grained UMLS types.}
  \label{tab:super-rels}
\end{minipage}
\hfill
\begin{minipage}[t]{0.73\textwidth}
%\mbox{}\\[-\baselineskip]
  \centering
  \frame{
    \begin{tabular}[t]{l l}
      \texttt{beneficial} (\textsc{b}) & {\small may\_treat, may\_prevent, treats, prevents}             \\[5pt]
      \texttt{harmful} (\textsc{h})    & {\small cause\_of, causative\_agent\_of, contraindicated\_drug} \\
    \end{tabular}
  }
\end{minipage}
\end{table}

但它的结果与我想要的相差甚远: 未对齐的小页面问题

我想要的是右侧小页面框架的顶部水平线应该与左侧小页面标题的顶部文本行对齐。

笔记:取消注释这些\mbox{}\\[-\baselineskip]行对最终的 pdf 输出完全没有影响。

附加信息(序言中可能相关的部分):

\documentclass[11pt,oneside]{book}
%% preamble based on http://www.khirevich.com/latex %%
\usepackage[DIV=14,BCOR=2mm,headinclude=true,footinclude=false]{typearea}
\usepackage[T1]{fontenc}
\usepackage{charter}
\usepackage[activate={true,           % activate protrusion
                  nocompatibility % activate expansion
                 },
        final,                    % enable microtype (disable: "draft")
        tracking=true,            % activate tracking
        kerning=true,             % activate kerning
        spacing=true,             % activate spacing
        factor=1100,              % add 10% to protrusion (default: 1000)
        stretch=10,shrink=10]     % reduce streching/shrinking (default: 20/20)
        {microtype}
\microtypecontext{spacing=nonfrench}
\usepackage[automark,headsepline,nouppercase]{scrpage2}
\usepackage{wrapfig}

\pagestyle{scrheadings}

答案1

\raisebox{-\height}{whatever}将基线移至 的最顶端{whatever}。显然设置\abovecaptionskip=0pt也会将标题对齐到最顶端。

\documentclass{article}

\begin{document}
\begin{table}[!t]
\begin{minipage}[t]{0.25\textwidth}
  \abovecaptionskip=0pt
  \caption{The two ``super''-relations and their constituent fine-grained UMLS types.}
  \label{tab:super-rels}
\end{minipage}
\hfill
\begin{minipage}[t]{0.73\textwidth}
%\mbox{}\\[-\baselineskip]
  \centering
  \raisebox{-\height}{\frame{
    \begin{tabular}[t]{l l}
      \texttt{beneficial} (\textsc{b}) & {\small may\_treat, may\_prevent, treats, prevents}             \\[5pt]
      \texttt{harmful} (\textsc{h})    & {\small cause\_of, causative\_agent\_of, contraindicated\_drug} \\
    \end{tabular}
  }}
\end{minipage}
\end{table}
\end{document}

侧边标题

答案2

在此处输入图片描述

\documentclass[11pt,oneside]{book}
\usepackage[DIV=14,BCOR=2mm,headinclude=true,footinclude=false]{typearea}
\usepackage[T1]{fontenc}
\usepackage{charter,tabularx}
\usepackage[activate={true,       % activate protrusion
        nocompatibility},         % activate expansion                 
        final,                    % enable microtype (disable: "draft")
        tracking=true,            % activate tracking
        kerning=true,             % activate kerning
        spacing=true,             % activate spacing
        factor=1100,              % add 10% to protrusion (default: 1000)
        stretch=10,shrink=10]     % reduce streching/shrinking (default: 20/20)
        {microtype}
\begin{document}

\begin{table}\centering
\begin{tabularx}{0.28\textwidth}[t]{X} 
\abovecaptionskip=0pt
\caption{The two ``super''-relations and their constituent fine-grained UMLS types.}
\label{tab:super-rels}
\end{tabularx}
\hfill
\begin{tabularx}{0.7\textwidth}[t]{|lX|} \hline
\texttt{beneficial} (\textsc{b}) & {\small may\_treat, may\_prevent, treats, prevents}             \\[5pt]
\texttt{harmful} (\textsc{h})    & {\small cause\_of, causative\_agent\_of, contraindicated\_drug} \\ \hline
\end{tabularx}
\end{table}

\end{document}

两个tabularxes 可以做与 s 相同的事情minipage,因为它们具有可选的定位参数(默认为 t、b、c)。但这里的主要问题是 a 与\caption普通文本不同,因为它具有\abovecaptionskip默认情况下不为零的 an。

首先,我们设置\abovecaptionskip=0pt,然后使用[t]两个tabularxes 的定位选项来保持两个顶部对齐。

相关内容