三部分表和 TexWorks 的问题

三部分表和 TexWorks 的问题

我正在将一些 latex 代码从 sharelatex 转移到 texworks,虽然此代码在 sharelatex 中运行正常,但在 texworks 中的三个 parttable 上似乎出现了问题。知道我做错了什么吗?

谢谢!

\documentclass[portrait 12pt]{article}
\usepackage[left=1in,top=1in,right=1in,bottom=1in,nohead,nofoot]{geometry}
\usepackage{booktabs}
\usepackage{lscape}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage[normalem]{ulem}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{hyperref}
\usepackage{float}
\usepackage{adjustbox}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usepackage{color}
\usepackage{caption}
\usepackage{amsmath}

\setlength{\parskip}{.25cm}
\setlength\parindent{0pt}

\setcounter{tocdepth}{1}

\newcommand{\sym}[1]{{#1}}
\title{Tablet Data Report}
\author{Cory}
\date{}

\def \OutputPath {"C:/Users/ifmr/Dropbox/Education v2/Clean Data Pipes, 2018/Analysis/launcher/Output/"}

\begin{document}
\maketitle

\section{Summary Statistics}

\begin{table}[H]
    \caption{Cumulative Session Length (Hours)}
    \label{}
    \begin{center}
        \resizebox{300pt}{!}{
            \begin{threeparttable}
                \begin{tabular}{4*{6}c}
                    \input{\OutputPath Tables/cumulative_length}
                \end{tabular}
                \begin{tablenotes}
                \end{tablenotes}
            \end{threeparttable}
        }
    \end{center}
\end{table}


\begin{figure}[H]
    \centering
    \includegraphics[width=0.6\linewidth]{\OutputPath Graphs/weekly_duration}
        \caption{Average Session Length By Week}
\end{figure}

\end{document}

该表的实际代码如下:

 & \multicolumn{6}{c}{\textbf{Class}} \\
\textbf{School}&\textbf{1}&\textbf{2}&\textbf{3}&\textbf{4}&\textbf{5}&\textbf{Total} \\
\midrule
Asharfabad&2.13&1.87&2.28&2.95&2.56&11.78 \\
RN3&0.24&0.00&0.00&0.00&0.63&0.86 \\
Seiko&0.00&0.00&0.00&0.00&0.75&0.75 \\

答案1

如果你想放一张没有\item用的纸条paratablenotes选项的注释。

而且:

  1. 看着何时应使用 \begin{center} 而不是 \centering?
  2. 避免使用resizebox调整表格大小,最好使用适当的字体,例如\large(但在这种情况下,正常尺寸标题很糟糕,在我看来,我根本不会改变字体)。
  3. 因为您已加载dcolumn,因此请使用它来获得更好的数字对齐。

我还加载了array在行之间添加一些空间的修改\arraystretch

\documentclass[portrait 12pt]{article}
\usepackage[left=1in,top=1in,right=1in,bottom=1in,nohead,nofoot]{geometry}
\usepackage{array}
\renewcommand{\arraystretch}{1.2}
\usepackage{booktabs}
\usepackage{lscape}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{dcolumn}
 \newcolumntype{d}[1]{D{.}{.}{#1}}
\usepackage[normalem]{ulem}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{hyperref}
\usepackage{float}
\usepackage{adjustbox}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usepackage{color}
\usepackage{caption}
\usepackage{amsmath}

\setlength{\parskip}{.25cm}
\setlength\parindent{0pt}

\setcounter{tocdepth}{1}

\newcommand{\sym}[1]{{#1}}
\title{Tablet Data Report}
\author{Cory}
\date{}

\def \OutputPath {"C:/Users/ifmr/Dropbox/Education v2/Clean Data Pipes, 2018/Analysis/launcher/Output/"}

\begin{document}
    \maketitle

    \section{Summary Statistics}

    \begin{table}[H]\centering\large
        \caption{Cumulative Session Length (Hours)\label{alabel}}
        \begin{threeparttable}
            \begin{tabular}{l*{5}{d{1.2}}d{2.2}}
                & \multicolumn{5}{c}{\textbf{Class}} \\
                \cmidrule(lr){2-6}
                \textbf{School}&\multicolumn{1}{c}{\textbf{1}}&\multicolumn{1}{c}{\textbf{2}}&\multicolumn{1}{c}{\textbf{3}}&\multicolumn{1}{c}{\textbf{4}}&\multicolumn{1}{c}{\textbf{5}}&\multicolumn{1}{c}{\textbf{Total}} \\
                \midrule
                Asharfabad&2.13&1.87&2.28&2.95&2.56&11.78 \\
                RN3&0.24&0.00&0.00&0.00&0.63&0.86 \\
                Seiko&0.00&0.00&0.00&0.00&0.75&0.75 \\
                \bottomrule
            \end{tabular}
        \begin{tablenotes}[para,flushleft]
            If your table doesn't have a note, why do you use threeparttable?
        \end{tablenotes}
        \end{threeparttable}
    \end{table}

    \begin{figure}[H]
        \centering
        \includegraphics[width=0.6\linewidth]{example-image-a}
        \caption{Average Session Length By Week}
    \end{figure}

\end{document}

在此处输入图片描述

编辑:

由于您无法更改输入文件,因此我认为最好的对齐方式是r

\begin{filecontents*}{cumulative_length.tex}
& \multicolumn{6}{c}{\textbf{Class}} \\
\textbf{School}&\textbf{1}&\textbf{2}&\textbf{3}&\textbf{4}&\textbf{5}&\textbf{Total} \\
\midrule
Asharfabad&2.13&1.87&2.28&2.95&2.56&11.78 \\
RN3&0.24&0.00&0.00&0.00&0.63&0.86 \\
Seiko&0.00&0.00&0.00&0.00&0.75&0.75 \\
\end{filecontents*}

\documentclass[portrait 12pt]{article} 
\usepackage[left=1in,top=1in,right=1in,bottom=1in,nohead,nofoot]{geometry} 
\usepackage{array} 
\renewcommand{\arraystretch}{1.2} 
\usepackage{booktabs} 
\usepackage{lscape} 
\usepackage{graphicx} 
\usepackage{caption} 
\usepackage{subcaption} 
\usepackage{booktabs} 
\usepackage{dcolumn} 
\newcolumntype{d}[1]{D{.}{.}{#1}} 
\usepackage[normalem]{ulem} 
\usepackage{rotating} 
\usepackage{threeparttable} 
\usepackage{multirow} 
\usepackage{multicol} 
\usepackage{hyperref} 
\usepackage{float} 
\usepackage{adjustbox} 
\usepackage[utf8]{inputenc} 
\usepackage{verbatim} 
\usepackage{color} 
\usepackage{caption} 
\usepackage{amsmath} 
\setlength{\parskip}{.25cm} 
\setlength\parindent{0pt} 
\setcounter{tocdepth}{1} 
\newcommand{\sym}[1]{{#1}} 
\title{Tablet Data Report} 
\author{Cory} 
\date{} 
\def \OutputPath {"C:/Users/ifmr/Dropbox/Education v2/Clean Data Pipes, 2018/Analysis/launcher/Output/"} 
\begin{document} 
\maketitle \section{Summary Statistics} 
\begin{table}[H]\centering\large 
\caption{Cumulative Session Length (Hours)\label{alabel}} 
\begin{threeparttable} 
\begin{tabular}{l*{6}{r}}
\toprule
 \input{cumulative_length}
\bottomrule 
\end{tabular} 
\begin{tablenotes}[para,flushleft] 
If your table doesn't have a note, why do you use threeparttable? 
\end{tablenotes} 
\end{threeparttable} 
\end{table} 
\begin{figure}[H]\centering 
\includegraphics[width=0.6\linewidth]{example-image-a} 
\caption{Average Session Length By Week}
\end{figure} 
\end{document}

在此处输入图片描述

相关内容