booktabs 테이블의 전체 크기 수정

booktabs 테이블의 전체 크기 수정

내가 만들려고하는 테이블은 다음과 같습니다.

\documentclass{book}
\usepackage{tabularx, booktabs}
\usepackage{lipsum}

\begin{document}
\begin{table}
\centering


\begin{tabularx}{\textwidth}{lll}

 \toprule
Conditions & Items test corrects & Items test incorrects \\
 \midrule
 Non-adjacents & Fa\textunderscore Sol\textunderscore Ré\textunderscore (O\textunderscore P\textunderscore Q\textunderscore ) & *Do\#\textunderscore Sol\#\textunderscore Si (S\textunderscore R\textunderscore T) \\
 & Sol\#\textunderscore Do\#\textunderscore Si\textunderscore  (R\textunderscore S\textunderscore T) & *Ré\textunderscore Sol\textunderscore Fa (Q\textunderscore P\textunderscore O) \\
 & \textunderscore Do\textunderscore Fa\#\textunderscore Ré\# (\textunderscore u\textunderscore v\textunderscore w) & *La\textunderscore Mi\textunderscore La\# (\textunderscore y\textunderscore x\textunderscore z) \\
 & \textunderscore Mi\textunderscore La\textunderscore La\# (\textunderscore x\textunderscore y\textunderscore z) & *Ré\#\textunderscore Fa\#\textunderscore Do (\textunderscore w\textunderscore v\textunderscore u) \\
Adjacents &  Ré.Ré\#.Fa.Do.Sol.Fa\# (QwOuPv) & *Si.La.Sol\#.La\#.Do\#.Mi (TyRzSx) \\ 
 & Ré.La\#.Fa.Mi.Sol.La (QzOxPy) & *Si.Fa\#.Sol\#.Ré\#.Do\#.Do (TvRwSu) \\ 
 & Si.Ré\#.Sol\#.Do.Do\#.Fa\# (TwRuSv) & *Ré.La.Fa.La\#.Sol.Mi (QyOzPx) \\ 
 & Si.La\#.Sol\#.Mi.Do\#.La (TzRxSy) & *Ré.Fa\#.Fa.Ré\#.Sol.Do QvOwPu) \\ 
 \bottomrule 

\end{tabularx}

\end{table}

\lipsum

\end{document}

결과는 다음과 같습니다:

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

표의 너비를 줄이려고 했지만 \footnotesize표의 텍스트가 여전히 오른쪽 여백을 약간 벗어났습니다.

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

질문:

책탭을 사용하여 모든 표를 텍스트와 정렬되도록 강제하는 방법이 있습니까?

답변1

tabularx내 생각에는 당신은 원하지 않는 것 같아요 .

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{lipsum}

\newcommand{\sh}{$\sharp$}

\begin{document}
\lipsum[2]

\begin{table}[htp]
\centering
\footnotesize

\begin{tabular}{lll}
 \toprule
Conditions & Items test corrects & Items test incorrects \\
 \midrule
Non-adjacents & Fa\_Sol\_Ré\_(O\_P\_Q\_) & *Do\sh\_Sol\sh\_Si (S\_R\_T) \\
 & Sol\sh\_Do\sh\_Si\_ (R\_S\_T) & *Ré\_Sol\_Fa (Q\_P\_O) \\
 & \_Do\_Fa\sh\_Ré\sh (\_u\_v\_w) & *La\_Mi\_La\sh (\_y\_x\_z) \\
 & \_Mi\_La\_La\sh (\_x\_y\_z) & *Ré\sh\_Fa\sh\_Do (\_w\_v\_u) \\
Adjacents &  Ré.Ré\sh.Fa.Do.Sol.Fa\sh (QwOuPv) & *Si.La.Sol\sh.La\sh.Do\sh.Mi (TyRzSx) \\
 & Ré.La\sh.Fa.Mi.Sol.La (QzOxPy) & *Si.Fa\sh.Sol\sh.Ré\sh.Do\sh.Do (TvRwSu) \\
 & Si.Ré\sh.Sol\sh.Do.Do\sh.Fa\sh (TwRuSv) & *Ré.La.Fa.La\sh.Sol.Mi (QyOzPx) \\
 & Si.La\sh.Sol\sh.Mi.Do\sh.La (TzRxSy) & *Ré.Fa\sh.Fa.Ré\sh.Sol.Do QvOwPu) \\
 \bottomrule
\end{tabular}

\end{table}

\lipsum[3]

\end{document}

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

으로 동일한 작업을 시도하면 \begin{tabularx}{lXX}한 줄이 두 행으로 분할됩니다(테이블에 하이픈 넣기를 비활성화하지 않는 한 잘못된 하이픈이 포함됨). 더 나은 결과는 사양입니다 @{}lXX@{}.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{tabularx,booktabs}
\usepackage{lipsum}

\newcommand{\sh}{$\sharp$}

\begin{document}
\lipsum[2]

\begin{table}[htp]
\centering
\footnotesize
\hyphenpenalty=10000
\begin{tabularx}{\textwidth}{@{}lXX@{}}
 \toprule
Conditions & Items test corrects & Items test incorrects \\
 \midrule
Non-adjacents & Fa\_Sol\_Ré\_(O\_P\_Q\_) & *Do\sh\_Sol\sh\_Si (S\_R\_T) \\
 & Sol\sh\_Do\sh\_Si\_ (R\_S\_T) & *Ré\_Sol\_Fa (Q\_P\_O) \\
 & \_Do\_Fa\sh\_Ré\sh (\_u\_v\_w) & *La\_Mi\_La\sh (\_y\_x\_z) \\
 & \_Mi\_La\_La\sh (\_x\_y\_z) & *Ré\sh\_Fa\sh\_Do (\_w\_v\_u) \\
Adjacents &  Ré.Ré\sh.Fa.Do.Sol.Fa\sh (QwOuPv) & *Si.La.Sol\sh.La\sh.Do\sh.Mi (TyRzSx) \\
 & Ré.La\sh.Fa.Mi.Sol.La (QzOxPy) & *Si.Fa\sh.Sol\sh.Ré\sh.Do\sh.Do (TvRwSu) \\
 & Si.Ré\sh.Sol\sh.Do.Do\sh.Fa\sh (TwRuSv) & *Ré.La.Fa.La\sh.Sol.Mi (QyOzPx) \\
 & Si.La\sh.Sol\sh.Mi.Do\sh.La (TzRxSy) & *Ré.Fa\sh.Fa.Ré\sh.Sol.Do QvOwPu) \\
 \bottomrule
\end{tabularx}

\end{table}

\lipsum[3]

\end{document}

그러나 결과는 텍스트 너비에 따라 변경됩니다.

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

참고하세요tabularx 필요X작동하려면 최소한 하나의 열.

또한 이는 \#날카로운 기호에 대한 올바른 기호가 아니라는 점에 유의하십시오. 나는 다음 \sh과 같이 정의했습니다 $\sharp$(해당 \sharp명령은 기본적으로 수학 모드에서만 사용할 수 있습니다).

답변2

l( cr너무) 열은 내용이 일부 제한에 도달해도 중단되지 않습니다. tabularx총 너비를 사용하고 있으므로 \textwidth더 나을 것입니다.

\begin{tabularx}{\textwidth}{lXX}     %%<-- note 2 X columns.

여기서 X열은 끝에 도달하면 내용이 끊어지는 동일한 너비의 열을 제공합니다.

\documentclass{book}
\usepackage{tabularx, booktabs}
\usepackage{lipsum}

\begin{document}
\begin{table}
\centering


\begin{tabularx}{\textwidth}{lXX}

 \toprule
Conditions & Items test corrects & Items test incorrects \\
 \midrule
 Non-adjacents & Fa\textunderscore Sol\textunderscore Ré\textunderscore (O\textunderscore P\textunderscore Q\textunderscore ) & *Do\#\textunderscore Sol\#\textunderscore Si (S\textunderscore R\textunderscore T) \\
 & Sol\#\textunderscore Do\#\textunderscore Si\textunderscore  (R\textunderscore S\textunderscore T) & *Ré\textunderscore Sol\textunderscore Fa (Q\textunderscore P\textunderscore O) \\
 & \textunderscore Do\textunderscore Fa\#\textunderscore Ré\# (\textunderscore u\textunderscore v\textunderscore w) & *La\textunderscore Mi\textunderscore La\# (\textunderscore y\textunderscore x\textunderscore z) \\
 & \textunderscore Mi\textunderscore La\textunderscore La\# (\textunderscore x\textunderscore y\textunderscore z) & *Ré\#\textunderscore Fa\#\textunderscore Do (\textunderscore w\textunderscore v\textunderscore u) \\
Adjacents &  Ré.Ré\#.Fa.Do.Sol.Fa\# (QwOuPv) & *Si.La.Sol\#.La\#.Do\#.Mi (TyRzSx) \\
 & Ré.La\#.Fa.Mi.Sol.La (QzOxPy) & *Si.Fa\#.Sol\#.Ré\#.Do\#.Do (TvRwSu) \\
 & Si.Ré\#.Sol\#.Do.Do\#.Fa\# (TwRuSv) & *Ré.La.Fa.La\#.Sol.Mi (QyOzPx) \\
 & Si.La\#.Sol\#.Mi.Do\#.La (TzRxSy) & *Ré.Fa\#.Fa.Ré\#.Sol.Do QvOwPu) \\
 \bottomrule

\end{tabularx}

\end{table}

\lipsum

\end{document}

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

관련 정보