![Word 到 LaTeX 转换后的表格放错了位置,请帮忙修复问题](https://linux22.com/image/321184/Word%20%E5%88%B0%20LaTeX%20%E8%BD%AC%E6%8D%A2%E5%90%8E%E7%9A%84%E8%A1%A8%E6%A0%BC%E6%94%BE%E9%94%99%E4%BA%86%E4%BD%8D%E7%BD%AE%EF%BC%8C%E8%AF%B7%E5%B8%AE%E5%BF%99%E4%BF%AE%E5%A4%8D%E9%97%AE%E9%A2%98.png)
我编辑了 Word 中的表格,以解决其复杂性(数学公式、合并单元格……),并使用 GrindEQ Math Word-to-LaTeX 转换器将其转换为 LaTeX 版本。问题是代码无法在我的 LaTeX 论文中呈现合适的外观。表格是水平的,而我的论文是纵向模式,这就是表格超出页面限制的原因。我希望它与段落具有相同的宽度。
\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[pdftex]{graphicx}
\begin{document}
\begin{tabular}{|p{1in}|p{0.6in}|p{1.0in}|p{0.6in}|p{1.0in}|p{0.6in}|p{0.3in}|p{1.0in}|p{0.6in}|p{1.0in}|} \hline
& \textbf{BANK} & \multicolumn{2}{|p{1.6in}|}{\textbf{Participant 1}} & \multicolumn{2}{|p{1.6in}|}{\textbf{Participant 2}} & \textbf{\dots } & \multicolumn{2}{|p{1.6in}|}{\textbf{Participant (n-1)}} & \textbf{Participant n} \\ \hline
& \textbf{Investing option} & \textbf{Take-up option} & \textbf{Investing option} & \textbf{Take-up option} & \textbf{Investing option} & \textbf{\dots } & \textbf{Take-up option} & \textbf{Investing option} & \textbf{Investing option} \\ \hline
\textbf{T${}_{1}$} & $C\times (n+1)$\textit{} & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & \textit{\dots } & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & $-\ C$\textit{} \\ \hline
\textbf{T${}_{2}$} & $-\ C$\textit{} & $C\times (n+1)\times (1-w_1)$\textit{} & $-\ C$\textit{} & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & \textit{\dots } & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & $-\ C$\textit{} \\ \hline
\textbf{T${}_{3}$} & $-\ C$\textit{} & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & $C\times (n+1)\times (1-w_2)$\textit{} & $-\ C$\textit{} & \textit{\dots } & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & $-\ C$\textit{} \\ \hline
\textbf{\dots } & \textit{\dots } & \textit{\dots } & \textit{\dots } & \textit{\dots } & \textit{\dots } & \textit{} & \textit{\dots } & \textit{\dots } & \textit{\dots } \\ \hline
\textbf{T${}_{n}$} & $-\ C$\textit{} & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & \multicolumn{2}{|p{1.6in}|}{$-\ C$\textit{}} & \textit{\dots } & $C\times (n+1)\times (1-w_{n-1})$\textit{} & $-\ C$\textit{} & $-\ C$\textit{} \\ \hline
\textbf{T${}_{n+1}$} & $-\ C$\textit{} & $-\ C+[C\times (n+1)\times w_1]$\textit{} & $-\ C$\textit{} & $-\ C+[C\times (n+1)\times w_2]$\textit{} & $-\ C$\textit{} & \textit{\dots } & $-\ C+[C\times (n+1)\times w_{n-1}]$\textit{} & $-\ C$\textit{} & $C\times (n+1)$\textit{} \\ \hline
\textbf{Capital at the end of the cycle} & $\left[C\times (n+1)\times \left(1+r\right)\right]+[C\times \left(n+1\right)\times \sum^n_{i=1}{{(1+rq}_n})]$\textit{} & $C\times (n+1)$\textit{} & $\left[C\times (n+1)\times \left(1+rp_1\right)\right]$\textit{} & $C\times (n+1)$\textit{} & $\left[C\times (n+1)\times \left(1+rp_2\right)\right]$\textit{} & \textit{\dots } & $C\times (n+1)$\textit{} & $\left[C\times n\times \left(1+rp_{n-1}\right)\right]$\textit{} & $\left[C\times (n+1)\times \left(1+rp_n\right)\right]$\textit{} \\ \hline
\end{tabular}
答案1
以下解决方案使用
将表格材料放置在横向模式中的包
rotating
及其环境,sidewaystable
该
tabularx
包及其tabularx
包允许在 8 个主要数据列中自动换行,包
ragged2e
及其宏用于创建允许连字符(如果需要)的列类型\Centering
的居中版本,X
包
booktabs
及其线条绘制宏(\toprule
、\midrule
、\bottomrule
和),以及完全不存在任何垂直规则,使表格呈现“开放”的外观,\cmidrule
并且\addlinespace
和
xcolor
包colortbl
将其中六个单元格渲染成浅灰色。
有了这样的设置,从桌子的上部移动到下部时不再需要反复伸长脖子。
注意我已经废除了所有大胆的——根本就没有必要。
\documentclass{article}
\usepackage{amssymb,amsmath}
\usepackage[table,x11names]{xcolor}
\usepackage{rotating,tabularx,ragged2e,booktabs}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters suitably
\newcommand\abtimes{\allowbreak\times}
\begin{document}
\begin{sidewaystable}
\renewcommand{\tabularxcolumn}[1]{m{#1}} % center cell contents vertically
\setlength\tabcolsep{3pt}
\begin{tabularx}{\textwidth}{@{} P{0.8in} *{5}{C} c *{3}{C} @{} P{1sp} @{}}
\toprule
& Bank
& \multicolumn{2}{c}{Participant 1} & \multicolumn{2}{c}{Participant 2}
& $\cdots$
& \multicolumn{2}{c}{Participant $n-1$} & Participant $n$ & \\
\cmidrule(lr){2-2} \cmidrule(lr){3-4} \cmidrule(lr){5-6}
\cmidrule(lr){8-9} \cmidrule(l){10-10}
& Investing option
& Take-up option & Investing option
& Take-up option & Investing option
& $\cdots$
& Take-up option & Investing option
& Investing option & \\
\midrule
$T_{1}$ & $C\abtimes (n+1)$
& \multicolumn{2}{c}{$-C$} & \multicolumn{2}{c}{$-C$}
& $\cdots$
& \multicolumn{2}{c}{$-C$} & $-C$ & \\ \addlinespace
$T_{2}$ & $-C$
& \cellcolor{Snow2} $C\abtimes(n+1)\abtimes(1-w_1)$
& \cellcolor{Snow2} $-C$
& \multicolumn{2}{c}{$-C$} & $\cdots$
& \multicolumn{2}{c}{$-C$} & $-C$ & \\ \addlinespace
$T_{3}$ & $-C$ & \multicolumn{2}{c}{$-C$}
& \cellcolor{Snow2} $C\abtimes (n+1)\abtimes (1-w_2)$
& \cellcolor{Snow2} $-C$ & $\cdots$
& \multicolumn{2}{c}{$-C$} & $-C$ \\
$\vdots$ & & & & & & $\vdots$ \\
$T_{n}$ & $-C$
& \multicolumn{2}{c}{$-C$}
& \multicolumn{2}{c}{$-C$} & $\cdots$
& \cellcolor{Snow2} $C\abtimes (n+1)\abtimes (1-w_{n-1})$
& \cellcolor{Snow2} $-C$ & $-C$ & \\\addlinespace\addlinespace
$T_{n+1}$ & $-C$
& $-C+[C\times (n+1)\abtimes w_1]$ & $-C$
& $-C+[C\times (n+1)\abtimes w_2]$ & $-C$ & $\cdots$
& $-C+[C\times (n+1)\abtimes w_{n-1}]$ & $-C$
& $C\abtimes (n+1)$ & \\ \addlinespace\addlinespace
Capital at end of cycle
& $[C\abtimes (n+1)\abtimes (1+r)]+\allowbreak[C\times (n+1)\abtimes \sum^n_{i=1}(1+rq_n)]$
& $C\abtimes (n+1)$
& $C\abtimes (n+1)\abtimes (1+rp_1)$
& $C\abtimes (n+1)$ & $C\abtimes (n+1) \abtimes (1+rp_2)$
& $\cdots$
& $C\abtimes (n+1)$ & $C\abtimes (n+1) \abtimes (1+rp_{n-1})$
& $C\abtimes (n+1)\abtimes (1+rp_n)$ & \\
\bottomrule
\end{tabularx}
\end{sidewaystable}
\end{document}