테이블의 정렬은 헤더 길이에 따라 달라집니다.

테이블의 정렬은 헤더 길이에 따라 달라집니다.

코드(또는 긴 텍스트)에서 "헤더에 사용된 일반 변수" 헤더를 삭제하면 두 열이 다음과 같이 겹칩니다.

현재 출력:

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

현재 코드:

\documentclass[12pt,twoside]{book}
  \usepackage[a4paper, hmargin={2.5cm, 2.5cm}, vmargin={2.5cm, 2.5cm},bindingoffset=6mm]{geometry}      

  \usepackage{amsmath}                      
  \usepackage{mathtools} 
  \usepackage{tabularx}                     
  \usepackage{subcaption}
    \usepackage{booktabs}   

    \begin{document}
    \begin{table}[H] 
    \centering
    \begin{tabular}{lp{6cm}}
        \toprule
        \textbf{Variable} & \textbf{\hskip-1.2in Definition}   \\
        \midrule
        \textbf{General variables used in the model} \\
        $K$ & \hskip-1.2in Fixed amount of money need to start production \\
        $s$ & \hskip-1.2in Baseline quality of the good (normalized to 1) \\
        $n$ & \hskip-1.2in Number of people \\
        $\pi_1, \pi_2, \Pi$ & \hskip-1.2in%
 \vtop{\hsize=3.5in Profits of the entrepreneur in the first period ($\pi_1$),%
 in the second period ($\pi_2$) and total profits $\Pi = \pi_1 + \pi_1$)} \\
        $P_r$ & \hskip-1.2in $P_r$ is the regular price \\
        $\alpha$ & \hskip-1.2in $\alpha$ is specific for Case 1 \\
        \bottomrule
    \end{tabular}
     \vskip.1in\par
     {\textit{Note}: This table....
        \textit{Source}: Source to be inserted}
    \caption{Definition of variables}
    \label{table_alm}
\end{table}

  \end{document}

하지만 헤더를 유지하면 테이블이 괜찮아 보입니다. 이상적으로는 제목을 제거하고 다음과 같이 출력을 유지하고 싶습니다.

원하는 출력:

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

내가 도대체 ​​뭘 잘못하고있는 겁니까?

답변1

\begin{table}[!htb] 
    \centering
    \begin{tabular}{lp{6cm}}\toprule
        \textbf{Variable} & \textbf{ Definition}   \\
        \midrule
        \multicolumn{2}{c}{\textbf{General variables used in the model}} \\
        $K$ & Fixed amount of money need to start production \\
        $s$ & Baseline quality of the good (normalized to 1) \\
        $n$ & Number of people \\
        $\pi_1, \pi_2, \Pi$ & 
            Profits of the entrepreneur in the first period ($\pi_1$),%
            in the second period ($\pi_2$) and total profits ($\Pi = \pi_1 + \pi_1$) \\
        $P_r$ & $P_r$ is the regular price \\
        $\alpha$ & $\alpha$ is specific for Case 1 \\
        \bottomrule
    \end{tabular}

    \bigskip
    \textit{Note}: This table....
    \textit{Source}: Source to be inserted
    \caption{Definition of variables}\label{table_alm}
\end{table}

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

tabularxwith를 사용하는 것이 \begin{tabularx}{\linewidth}{lX}\toprule 더 의미가 있습니다.

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

그리고 두 번째 줄이 없으면:

    \begin{tabular}{lp{6cm}}\toprule
        \textbf{Variable} & \textbf{Definition}\\\midrule
        $K$ & Fixed amount of money need to start production \\
        ...

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

답변2

\vskip모든 지침 을 제거 \hskip하고 단순히 2열 tabularx환경을 사용하겠습니다. 그런데,굵은 글씨아껴서 사용하면 훨씬 더 효과적입니다.

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

\documentclass[12pt,twoside]{book}
\usepackage[a4paper, margin=2.5cm, bindingoffset=6mm]{geometry}
\usepackage{tabularx,booktabs}

\begin{document}    
\begin{table}
    \begin{tabularx}{\textwidth}{@{} l X @{}}
        \toprule
        \textbf{Variable} & \textbf{Definition}   \\
        \midrule
        \multicolumn{2}{@{}l}{General variables used in the model} \\[1ex]
        $K$ & Fixed amount of money need to start production \\
        $s$ & Baseline quality of the good (normalized to 1) \\
        $n$ & Number of people \\
        $\pi_1, \pi_2, \Pi$ & Profits of the entrepreneur in the first period ($\pi_1$), 
            profits in the second period~($\pi_2$), and total profits 
            ($\Pi = \pi_1 + \pi_1$) \\
        $P_r$ & $P_r$ is the regular price \\
        $\alpha$ & $\alpha$ is specific for Case 1 \\
        \bottomrule
    \end{tabularx}

    \bigskip
    \textit{Note}: This table \dots 

    \textit{Source}: Source to be inserted
    \caption{Definition of variables}
    \label{table_alm}
\end{table}
\end{document}

관련 정보