将表格从 word 转换为 latex

将表格从 word 转换为 latex

我对 overleaf 和编程都很陌生 - 我对表格感到很困惑。我的问题是我不知道如何将这个表格(来自 Word)转换为 LateX。

我知道这里需要多行和多列,但是列太多了,我不知所措在此处输入图片描述

真的很感谢一些帮助 - 我理解一般的命令(\hline,&等等),但我真的很难从头开始创建表格。

谢谢!

编辑:现在可以正常工作了!但是现在唯一的问题是表格的宽度似乎对于页面来说太大了...可能需要使用 \long table 或将其分成两部分跨越两页。请参阅:在此处输入图片描述

现在的代码是这样的:

\begin{table}[htbp]
  \centering
\caption{Overview of 'live' schools in contact with DSMF which will be distributing the survey.}\label{live schools}\\ 
    \begin{tabular}{p{5em}ccccccccc}
    \toprule
    \textbf{Level} &       & \multicolumn{1}{p{6.25em}}{\textbf{Type}} &       & \multicolumn{1}{p{5em}}{\textbf{Funding category}} &       & \multicolumn{1}{p{5em}}{\textbf{Gender}} &       & \multicolumn{1}{p{5em}}{\textbf{Country}} &  \\
    \midrule
    \multicolumn{1}{r}{} &       &       &       &       &       &       &       &       &  \\
    Secondary school & 431   & \multicolumn{1}{p{6.25em}}{Comprehensive} & 261   & \multicolumn{1}{p{5em}}{State} & 377   & \multicolumn{1}{p{5em}}{Mixed} & 394   & \multicolumn{1}{p{5em}}{England} & 465 \\
    \midrule
    Sixth Form College & 9     & \multicolumn{1}{p{6.25em}}{Selective} & 112   & \multicolumn{1}{p{5em}}{Independent} & 119   & \multicolumn{1}{p{5em}}{Boys only} & 24    & \multicolumn{1}{p{5em}}{Scotland} & 43 \\
    \midrule
    Further Education & 17    & \multicolumn{1}{p{6.25em}}{Faith} & 79    & \multicolumn{1}{p{5em}}{N/A} & 16    & \multicolumn{1}{p{5em}}{Girls only} & 59    & \multicolumn{1}{p{5em}}{Wales} & 1 \\
    \midrule
    Primary School & 28    & \multicolumn{1}{p{6.25em}}{Grammar} & 26    &       &       & \multicolumn{1}{p{5em}}{Boys with girls in Sixth Form} & 16    & \multicolumn{1}{p{5em}}{Switzerland} & 1 \\
    \midrule
    Pupil referral unit & 9     & \multicolumn{1}{p{6.25em}}{Alternative provision} & 12    &       &       & \multicolumn{1}{p{5em}}{Girls with boys in Sixth Form} & 10    & \multicolumn{1}{p{5em}}{Czech Republic} & 1 \\
    \midrule
    Prep School & 4     & \multicolumn{1}{p{6.25em}}{Free} & 10    &       &       & \multicolumn{1}{p{5em}}{N/A} & 10    & \multicolumn{1}{p{5em}}{Northern Ireland} & 1 \\
    \midrule
    Special school & 6     & \multicolumn{1}{p{6.25em}}{Non-selective} & 8     &       &       &       &       &       &  \\
    \midrule
    International school & 3     & \multicolumn{1}{p{6.25em}}{Free-Faith} & 4     &       &       &       &       &       &  \\
    \midrule
    University & 3     & \multicolumn{1}{p{6.25em}}{Other} & 2     &       &       &       &       &       &  \\
    \midrule
    Adult Education & 1     & \multicolumn{1}{p{6.25em}}{Missing data} & 10    &       &       &       &       &       &  \\
    \midrule
    Conservatoire & 1     &       &       &       &       &       &       &       &  \\
    \midrule
    \textbf{Total schools} & \multicolumn{9}{c}{\textbf{512}} \\
    \midrule
    \textbf{Total schools} & \multicolumn{9}{c}{\multirow{2}[2]{*}{\textbf{480}}} \\
    \textit{(excl. Universities, Primary and Adult educations schools)} & \multicolumn{9}{c}{} \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

答案1

这是我为您的表格提出的建议,尽管您仍然强烈建议访问该链接:我的桌子放不下;我有什么办法吗?

在你的情况下,表格不适合的主要原因是c-column 类型,如果单元格中的文本太长,它不会插入分隔符,而p{}column 会插入分隔符,包括它的兄弟m{}b{}。后者的列是包的一部分大批,由表格型

在这种“冗长”的表格中,您可能还需要减小字体大小,但是如果您需要小于 的大小\footnotesize,在我看来,这表明表格可能需要重新考虑。另一种选择是垂直放置表格并利用可用空间来显示长文本。例如,您可以加载此包旋转并用 替代table环境sidewaystable

在这个例子中我使用了表格型使用更方便的X-column 类型;搜索此论坛以获取更多信息,例如这篇最新文章或阅读软件包文档

\documentclass{article}
\usepackage{lmodern,microtype}
\usepackage{tabularx}
\usepackage{booktabs}

\renewcommand{\arraystretch}{1.5}
\newcolumntype{Y}{>{\hsize=1.6\hsize\linewidth=\hsize\raggedright}X}
\newcolumntype{Z}{>{\hsize=0.4\hsize\linewidth=\hsize\raggedleft\arraybackslash}X}
\newcolumntype{M}{>{\hsize=2\hsize\linewidth=\hsize\centering\arraybackslash}X}

\begin{document}
\begin{table}[htbp]
  \caption{Overview of 'live' schools in contact with DSMF which will be distributing the survey.}\label{tab:liveschools}
  \scriptsize
  \centering
  \vspace{3pt}%
  \begin{tabularx}{\linewidth}{@{} *5{Y@{\hspace{0.25\tabcolsep}}Z} @{}}
    \toprule
    \multicolumn{2}{M}{\textbf{Level}}
    & \multicolumn{2}{M}{\textbf{Type}}
    & \multicolumn{2}{M}{\textbf{Funding category}}
    & \multicolumn{2}{M}{\textbf{Gender}}
    & \multicolumn{2}{M}{\textbf{Country}} \\
    \midrule
    Secondary school     & 431 & Comprehensive         & 261 & State       & 377 & Mixed                         & 394 & England          & 465 \\
    Sixth Form College   & 9   & Selective             & 112 & Independent & 119 & Boys only                     & 24  & Scotland         & 43  \\
    Further Education    & 17  & Faith                 & 79  & N/A         & 16  & Girls only                    & 59  & Wales            & 1   \\
    Primary School       & 28  & Grammar               & 26  &             &     & Boys with girls in Sixth Form & 16  & Switzerland      & 1   \\
    Pupil referral unit  & 9   & Alternative provision & 12  &             &     & Girls with boys in Sixth Form & 10  & Czech Republic   & 1   \\
    Prep School          & 4   & Free                  & 10  &             &     & N/A                           & 10  & Northern Ireland & 1   \\
    Special school       & 6   & Non-selective         & 8   &             &     &                               &     &                  &     \\
    International school & 3   & Free-Faith            & 4   &             &     &                               &     &                  &     \\
    University           & 3   & Other                 & 2   &             &     &                               &     &                  &     \\
    Adult Education      & 1   & Missing data          & 10  &             &     &                               &     &                  &     \\
    Conservatoire        & 1   &                       &     &             &     &                               &     &                  &     \\
    \midrule[\heavyrulewidth]
    \multicolumn{2}{@{}l}{\textbf{Total schools}}
    & \multicolumn{8}{l}{\textbf{512}} \\
    \midrule
    \multicolumn{2}{@{}l@{}}{\textbf{Total schools}\textsuperscript{\,1}}
    & \multicolumn{8}{l}{\textbf{480}} \\
    \bottomrule
    \multicolumn{10}{@{}l@{}}{\textsuperscript{1}\,\textit{(excl. Universities, Primary and Adult educations schools)}} \\
  \end{tabularx}
\end{table}
\end{document}

在此处输入图片描述

相关内容