我有一个如下所示的 tabularx{} 表,但不知道它为什么会浮动。提前致谢。
\documentclass[11pt,authoryear,sort&compress]{report}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage{cite}
\usepackage{multirow}
\usepackage{multicol}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}{>{\raggedleft\arraybackslash}X}
\newcolumntype{z}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[!ht]
\footnotesize
%\scriptsize
\centering
\begin{tabularx}{1\textwidth}{ll*{1}{l} }
\toprule
%& Variable name & Definition \\
Variable name & Definition \\
\midrule
\textit{\text{independent variables}} \\
\cline{1-1} \\
$x_1$ Gender & \textit{\text{male = 1, female = 0}} \\
$x_2$ Marital Status & \textit{\text{married/cohabited = 1, otherwise = 0 }} \\
$x_3$ Age & household's age in years \\
$x_4$ Employed & \textit{\text{employed = 1, otherwise = 0 }} \\
$x_5$ Education & \textit{\text{high school or higher = 1, otherwise = 0 }} \\
$x_6$ Party & \textit{\text{affiliation with Chinese Communist Party (CCP) = 1, otherwise = 0 }} \\
$x_7$ HR & \textit{\text{urban = 1, rural = 0 }} \\
$x_8$ Region & \textit{\text{west, east, and center.}} \\
$x_9$ Income & household's income in Chinese Renminbi (CNY). \\
$x_{10}$ Net-worth & The value of financial and non-financial assets minus liabilities in Chinese Renminbi (CNY). \\
$x_{11}$ NW-HE & Net-worth minus home equity in Chinese Renminbi (CNY). \\
$x_{12}$ Liquid Assets & Cash and other easily cash-able assets in Chinese Renminbi (CNY). \\
\midrule
\textit{\text{dependent variables}} \\ % & \underline{\textit{Does your household currently need loan? (n= 1458) }} \\
\cline{1-1} \\
$y_1$ Access to loan & \textit{\text{Access to loan = 1}} if the household head has any type of loan (e.g formal, informal, and/or both),
otherwise \textit{\text{Access to loan = 0}}. \\
$y_2$ Access to loan type & if the household head has formal, informal, or both loans \textit{\text{Access to loan type}} is equal to 1, 2, 3 respectively, otherwise \textit{\text{Access to loan type = 0}} which indicates the household head has not have any type of loan. \\
\bottomrule
\end{tabularx}
\caption{Definitions of the independent variables. \textit{Note: In equations $x_{10}$, $x_{11}$, and $x_{12}$ were use interchangeability. }}
\label{tab:def.of.varss}
\end{table}
\end{document}
答案1
我认为,主要问题是您未能&
在大多数列中插入对齐标记。
\documentclass[11pt]{report}
\usepackage{booktabs}
\usepackage{tabularx}
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\usepackage{amsmath}
\usepackage[normalem]{ulem}
\begin{document}
\begin{table}[!ht]
\begin{tabularx}{\textwidth}{@{} llR @{}}
\toprule
%& Variable name & Definition \\
\multicolumn{2}{@{}l}{Variable} & Definition \\
\midrule
\multicolumn{3}{@{}l}{\uline{\textit{independent variables}}} \\\addlinespace
$x_1$ & Gender & \textit{male${} = 1$, female${} = 0$} \\
$x_2$ & Marital Status & \textit{married\slash cohabited${} = 1$, otherwise${} = 0$ } \\
$x_3$ & Age & household's age, in years. \\
$x_4$ & Employed & \textit{employed${} = 1$, otherwise${} = 0$ } \\
$x_5$ & Education & \textit{high school or higher${} = 1$, otherwise${} = 0$ } \\
$x_6$ & Party & \textit{affiliation with Chinese Communist Party (CCP)${} = 1$, otherwise${} = 0$ } \\
$x_7$ & HR & \textit{urban${} = 1$, rural${} = 0$ } \\
$x_8$ & Region & \textit{west, east, \textup{and} center.} \\
$x_9$ & Income & household's income, in CNY. \\
$x_{10}$ & Net-worth & The value of financial and non-financial assets minus liabilities, in CNY.\\
$x_{11}$ & NW-HE & Net-worth minus home equity, in CNY.\\
$x_{12}$ & Liquid Assets & Cash and other easily cash-able assets, in CNY.\\ \\
\multicolumn{3}{@{}l}{\uline{\textit{dependent variables}}} \\\addlinespace
% & \underline{\textit{Does your household currently need loan? (n= 1458) }} \\
$y_1$ & Access to loan & \textit{Access to loan${} = 1$} if the household head has any type of loan (e.g formal, informal, and/or both); otherwise \textit{Access to loan${} = 0$}. \\
$y_2$ & Access to loan type & if the household head has formal, informal, or both loans \textit{Access to loan type} is equal to 1, 2, 3, respectively; otherwise \textit{Access to loan type${} =\allowbreak 0$}, which indicates the household head does not have any type of loan. \\
\bottomrule
\addlinespace
\multicolumn{3}{@{}p{\textwidth}@{}}{\footnotesize Note: In equations $x_{10}$, $x_{11}$, and $x_{12}$ were use interchangeability. } \\
\end{tabularx}
\caption{Definitions of the independent variables.}
\label{tab:def.of.varss}
\end{table}
\end{document}