줄에서 텍스트 분리하기

줄에서 텍스트 분리하기

나는 사용하고있다

\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}

여기에 이미지 설명을 입력하세요

대체 접근 방식

각 행 데이터를 변경할 필요가 없는 대체 솔루션입니다. 열 정의에 사용자 정의 Strut를 추가합니다.

\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}

관련 정보