將文字與行分離

將文字與行分離

我在用著

\documentclass[10pt]{article}

\begin{document}

\arrayrulewidth=0.7pt
\begin{tabular}{|c|c|l|c|c|c|l|}
\cline{1-3}\cline{5-7}
 &  & fun &  &  &  & first sight \\
1 & for & nothing &  & 5 & at & university \\
 &  & a chance &  &  &  & expense \\
\cline{1-3}\cline{5-7}
 &  & chance &  &  &  & control \\
2 & by & mistake &  & 6 & under & (her) breath \\
 &  & accident &  &  &  & investigation \\
\cline{1-3}\cline{5-7}
 &  & holiday &  &  &  & touch \\
3 & on & business &  & 7 & out of & luck \\
 &  & a diet &  &  &  & work \\
\cline{1-3}\cline{5-7}
 &  & trouble &  &  &  & A to Z \\
4 & in & a mess &  & 8 & from & scratch \\
 &  & the end &  &  &  & memory \\
\cline{1-3}\cline{5-7}
\end{tabular}

\end{document}

這會產生:

在此輸入影像描述

在第三列中,第一個單字非常接近台詞。有沒有辦法將這些單字與線條分開一點?

答案1

原始解決方案:

它既不漂亮也不自動,但在這裡我在每行的頂部單字中添加了一個 3pt 緩衝區(上方和下方)\addstackgap

\documentclass[10pt]{article}
\usepackage{stackengine}
\setstackgap{S}{3pt}
\begin{document}

\arrayrulewidth=0.7pt
\begin{tabular}{|c|c|l|c|c|c|l|}
\cline{1-3}\cline{5-7}
 &  &  \addstackgap{fun} &  &  &  & first sight \\
1 & for & nothing &  & 5 & at & university \\
 &  & a chance &  &  &  & expense \\
\cline{1-3}\cline{5-7}
 &  & \addstackgap{chance} &  &  &  & control \\
2 & by & mistake &  & 6 & under & (her) breath \\
 &  & accident &  &  &  & investigation \\
\cline{1-3}\cline{5-7}
 &  & \addstackgap{holiday} &  &  &  & touch \\
3 & on & business &  & 7 & out of & luck \\
 &  & a diet &  &  &  & work \\
\cline{1-3}\cline{5-7}
 &  & \addstackgap{trouble} &  &  &  & A to Z \\
4 & in & a mess &  & 8 & from & scratch \\
 &  & the end &  &  &  & memory \\
\cline{1-3}\cline{5-7}
\end{tabular}

\end{document}

在此輸入影像描述

替代方法

避免需要更改每行資料的替代解決方案。在列定義中新增自訂支柱。

\documentclass[10pt]{article}
\def\mystrut{\rule{0pt}{10pt}}
\begin{document}

\arrayrulewidth=0.7pt
\begin{tabular}{@{\mystrut}|c|c|l|c|c|c|l|}
\cline{1-3}\cline{5-7}
 &  &   fun &  &  &  & first sight \\
1 & for & nothing &  & 5 & at & university \\
 &  & a chance &  &  &  & expense \\
\cline{1-3}\cline{5-7}
 &  & chance &  &  &  & control \\
2 & by & mistake &  & 6 & under & (her) breath \\
 &  & accident &  &  &  & investigation \\
\cline{1-3}\cline{5-7}
 &  & holiday &  &  &  & touch \\
3 & on & business &  & 7 & out of & luck \\
 &  & a diet &  &  &  & work \\
\cline{1-3}\cline{5-7}
 &  & trouble &  &  &  & A to Z \\
4 & in & a mess &  & 8 & from & scratch \\
 &  & the end &  &  &  & memory \\
\cline{1-3}\cline{5-7}
\end{tabular}

\end{document}

在此輸入影像描述

答案2

\extrarowheight從包裝中取出使用array

雖然眼睛透過查看基線來測量從底部單字到規則的距離,但當到達頂部時,我們會查看上升部分。一些簡單的幾何形狀允許我們計算必要的額外高度。

\documentclass[10pt]{article}
\usepackage{array}

\begin{document}

\begin{center}
\setlength{\arrayrulewidth}{0.7pt}
\setlength{\extrarowheight}{%
  \dimexpr\dp\strutbox-\ht\strutbox+\fontcharht\font`A
}

\begin{tabular}{|c|c|l|c|c|c|l|}
\cline{1-3}\cline{5-7}
  &     & fun      &&   &        & first sight \\
1 & for & nothing  && 5 & at     & university \\
  &     & a chance &&   &        & expense \\
\cline{1-3}\cline{5-7}
  &     & chance   &&   &        & control \\
2 & by  & mistake  && 6 & under  & (her) breath \\
  &     & accident &&   &        & investigation \\
\cline{1-3}\cline{5-7}
  &     & holiday  &&   &        & touch \\
3 & on  & business && 7 & out of & luck \\
  &     & a diet   &&   &        & work \\
\cline{1-3}\cline{5-7}
  &     & trouble  &&   &        & A to Z \\
4 & in  & a mess   && 8 & from   & scratch \\
  &     & the end  &&   &        & memory \\
\cline{1-3}\cline{5-7}
\end{tabular}

\end{center}

\end{document}

在此輸入影像描述

這是一個不同的實作:

\documentclass[10pt]{article}
\usepackage{booktabs}

\begin{document}

\begin{center}

\begin{tabular}{llcll}
\cmidrule[\heavyrulewidth]{1-2}\cmidrule[\heavyrulewidth]{4-5}
1. \textit{for} & fun      && 5. \textit{at}     & first sight \\
                & nothing  &&                    & university \\
                & a chance &&                    & expense \\
\cmidrule[\heavyrulewidth]{1-2}\cmidrule[\heavyrulewidth]{4-5}
2. \textit{by}  & chance   && 6. \textit{under}  & control \\
                & mistake  &&                    & (her) breath \\
                & accident &&                    & investigation \\
\cmidrule[\heavyrulewidth]{1-2}\cmidrule[\heavyrulewidth]{4-5}
3. \textit{on}  & holiday  && 7. \textit{out of} & touch \\
                & business &&                    & luck \\
                & a diet   &&                    & work \\
\cmidrule[\heavyrulewidth]{1-2}\cmidrule[\heavyrulewidth]{4-5}
4. \textit{in}  & trouble  && 8. \textit{from}   & A to Z \\
                & a mess   &&                    & scratch \\
                & the end  &&                    & memory \\
\cmidrule[\heavyrulewidth]{1-2}\cmidrule[\heavyrulewidth]{4-5}
\end{tabular}

\end{center}

\end{document}

在此輸入影像描述

答案3

設定某種形式的\minrowclearance{<len>},這會將單元格內容和水平線之間的間隙至少增加到<len>

在此輸入影像描述

\documentclass{article}

\usepackage{colortbl}
\setlength{\minrowclearance}{5pt}

\begin{document}

\setlength{\arrayrulewidth}{0.7pt}

\begin{tabular}{|c|c|l|c|c|c|l|}
  \cline{1-3}\cline{5-7}
    &     & fun      &  &   &        & first sight \\
  1 & for & nothing  &  & 5 & at     & university \\
    &     & a chance &  &   &        & expense \\
  \cline{1-3}\cline{5-7}
    &     & chance   &  &   &        & control \\
  2 & by  & mistake  &  & 6 & under  & (her) breath \\
    &     & accident &  &   &        & investigation \\
  \cline{1-3}\cline{5-7}
    &     & holiday  &  &   &        & touch \\
  3 & on  & business &  & 7 & out of & luck \\
    &     & a diet   &  &   &        & work \\
  \cline{1-3}\cline{5-7}
    &     & trouble  &  &   &        & A to Z \\
  4 & in  & a mess   &  & 8 & from   & scratch \\
    &     & the end  &  &   &        & memory \\
  \cline{1-3}\cline{5-7}
\end{tabular}

\end{document}

相關內容