Longtable 不适合页边距

Longtable 不适合页边距

我是 LateX 的新手,并且真的很难解决页边距问题。

因此,系里给了我一个默认模板(我对序言和软件包做了一些调整)来写我的论文,这个模板将页边距限制了很多,但我试图让我的 longtable 忽略这些边距。我试过 \setlength\LTleft{-1cm} 和 \hspace*{-1cm},但它们就是不配合。另一个问题是表格的不同页面之间有交替的边距,这让我很困惑。

如何制作一个长表格,并在右侧/左侧自定义边距为 -1cm,或者如何缩小表格尺寸以适应预定的边距?

感谢大家提供的帮助:)

例如 在此处输入图片描述

在此处输入图片描述

以下是我的全部序言:

\documentclass[11pt]{book}

\usepackage{amsfonts, amsmath, amssymb}  
\usepackage{times}


\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}

\usepackage{booktabs, makecell, longtable}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

\usepackage{geometry}

\usepackage[usestackEOL]{stackengine}
\edef\tmp{\the\baselineskip}
\setstackgap{L}{\tmp}

\usepackage{enumitem}
\usepackage[backref=page,pagebackref=true,linkcolor = blue,citecolor = red]{hyperref}

\setlength{\oddsidemargin}{1.5cm}
\setlength{\evensidemargin}{0cm}
\setlength{\topmargin}{1mm}
\setlength{\headheight}{1.36cm}
\setlength{\headsep}{1.00cm}
\setlength{\textheight}{19cm}
\setlength{\textwidth}{14.5cm}
\setlength{\marginparsep}{1mm}
\setlength{\marginparwidth}{3cm}
\setlength{\footskip}{2.36cm}

下面是我的 chapter2/longtable 的一些代码:

\begin{document}
\pagestyle{empty}

\chapter{Methodologies}

This chapter details the population data, study variables, and visualisation techniques employed for the research

\section{Sample \& Measures}

Every 5 years \textit{The Census of Population and Dwellings} conducted by Statistics New Zealand provides a snapshot of our population, with the most recent census taking place during March 2018. However, this dissertation uses the 2013 Census (20/07/2017 refresh) dataset due to the most recent census results having yet to be released in the IDI. The usual resident population in 2013 of 4,242,048 acted as our base population. Restrictions of ages 15 and over were then applied to our base population because we wanted to attenuate the potential bias introduced by deprivation indicator variables such as income, education, and employment. Extraction and merging of census individual, census household, census area, census address, census dwelling, source ranked ethnicity, and IMD tables conducted via \textsc{SQL} which left a working-set sample of 3,482,712 counts. 

\begin{center}
% \setlength\LTleft{-1cm}
% \setlength\LTright{-1cm}
%\hspace*{-1cm}
\setlist[itemize]{topsep = 1ex, parsep =0pt, leftmargin=*,after=\vspace{-\baselineskip}}
\begin{longtable}{ll L{5.5cm} L{4.5cm}}
\caption{Table of 2013 Census variables used in this dissertation} 
\label{Table 2.1}\\
\toprule
\textbf{Variable} & \textbf{Census Code} & \textbf{Description} & \textbf{Study Variables} \\

\midrule
Sex & cen\_ind\_sex\_code & This variable was included as a baseline measurement. & 
\textbf{sex}:
\begin{itemize}
    \item[1.] Male 
    \item[2.] Female
\end{itemize} \\

\midrule
Age & cen\_ind\_age\_code & This variable captures the current age at the time of the 2013 census for an individual. We used both grouped age and mean age in our analysis. & 
\textbf{age\_group}: 
\begin{itemize} 
    \item[1.] 15 -- 24 
    \item[2.] 25 -- 34 
    \item[3.] 35 -- 44 
    \item[4.] 45 -- 54 
    \item[5.] 55 -- 64 
    \item[6.] 65 -- 74 
    \item[7.] \hspace{\parindent} $\geq$ 75
\end{itemize} \\ 

\midrule
Individual Income & cen\_ind\_grpd\_personal\_inc\_code & This variable captures the total before-tax personal income of an individual. & 
\textbf{personal\_income}: 
\begin{itemize}
    \item[1.] \$5,000 or Less 
    \item[2.] \$5,001 -- \$10,000 
    \item[3.] \$10,001 -- \$20,000 
    \item[4.] \$20,001 -- \$30,000 
    \item[5.] \$30,001 -- \$40,000 
    \item[6.] \$50,001 or More 
    \item[9.] Not Stated
\end{itemize} \\

\midrule
Household Income & cen\_hhd\_grpd\_hhld\_inc\_code & This variable captures the total income for a household, derived by taking the sum of the median individual income of all members whom reside together and share facilities in a private dwelling. & \textbf{household\_income}: 
\begin{itemize}
    \item[1.] \$20,000 or Less 
    \item[2.] \$20,001 -- \$30,000  
    \item[3.] \$30,001 -- \$50,000 
    \item[4.] \$50,001 -- \$70,000 
    \item[5.] \$70,001 --\$100,000 
    \item[6.] \$100,001 or More 
    \item[9.] Not Stated
\end{itemize} \\
\bottomrule
\end{longtable}
%\hspace*{-1cm}
\end{center}
\end{document}

答案1

我可以提供一个快速选项,即使用 lontabu,它是 tabu 包中 longtable 的扩展,您可以使用\linewidth比例维度分布因子(pddf){X[pddf] X[pddf] X[pddf] X[pddf]} 来控制单元的尺寸,在这种情况下......

\begin{longtabu} to \linewidth {X[0.5]X[1.5]XX} 

表示线宽按比例分布。表示 \linewidth = 0.4X+1.5X+X+X。

对于页数问题,书籍文档类默认为两面页,如果您的打印文档只有一页,只需将选项放在一边: \documentclass[11pt,oneside]{book}

结果: 在此处输入图片描述

梅威瑟:

% arara: pdflatex: {synctex: yes, action: nonstopmode}
\documentclass[11pt,oneside]{book}
\usepackage{amsfonts, amsmath, amssymb}  
\usepackage{times}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
\usepackage{booktabs,makecell,longtable,tabularx,tabu}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

\usepackage{geometry}

\usepackage[usestackEOL]{stackengine}
\edef\tmp{\the\baselineskip}
\setstackgap{L}{\tmp}

\usepackage{enumitem}
\usepackage[backref=page,pagebackref=true,linkcolor = blue,citecolor = red]{hyperref}

\setlength{\oddsidemargin}{1.5cm}
\setlength{\evensidemargin}{0cm}
\setlength{\topmargin}{1mm}
\setlength{\headheight}{1.36cm}
\setlength{\headsep}{1.00cm}
\setlength{\textheight}{19cm}
\setlength{\textwidth}{14.5cm}
\setlength{\marginparsep}{1mm}
\setlength{\marginparwidth}{3cm}
\setlength{\footskip}{2.36cm}

\begin{document}
    \pagestyle{empty}

    \chapter{Methodologies}

    This chapter details the population data, study variables, and visualisation techniques employed for the research

    \section{Sample \& Measures}

    Every 5 years \textit{The Census of Population and Dwellings} conducted by Statistics New Zealand provides a snapshot of our population, with the most recent census taking place during March 2018. However, this dissertation uses the 2013 Census (20/07/2017 refresh) dataset due to the most recent census results having yet to be released in the IDI. The usual resident population in 2013 of 4,242,048 acted as our base population. Restrictions of ages 15 and over were then applied to our base population because we wanted to attenuate the potential bias introduced by deprivation indicator variables such as income, education, and employment. Extraction and merging of census individual, census household, census area, census address, census dwelling, source ranked ethnicity, and IMD tables conducted via \textsc{SQL} which left a working-set sample of 3,482,712 counts. 

    \begin{center}
        % \setlength\LTleft{-1cm}
        % \setlength\LTright{-1cm}
        %\hspace*{-1cm}
        \small
        \tabulinesep = 1.5pt
        \setlist[itemize]{topsep = 1ex, parsep =0pt, leftmargin=*,after=\vspace{-\baselineskip}}
        \begin{longtabu} to \linewidth {X[0.5]X[1.5]XX}
            \caption{Table of 2013 Census variables used in this dissertation} 
            \label{Table 2.1}\\
            \toprule
            \rowfont{\bf}
            Variable & Census Code & Description & Study Variables \\ \midrule
            \endhead    
            Sex & cen\_ind\_sex\_code & This variable was included as a baseline measurement. & 
            \bf{sex}:
            \begin{itemize}
                \item[1.] Male 
                \item[2.] Female
            \end{itemize} \\

            \midrule
            Age & cen\_ind\_age\_code & This variable captures the current age at the time of the 2013 census for an individual. We used both grouped age and mean age in our analysis. & 
            \textbf{age\_group}: 
            \begin{itemize} 
                \item[1.] 15 -- 24 
                \item[2.] 25 -- 34 
                \item[3.] 35 -- 44 
                \item[4.] 45 -- 54 
                \item[5.] 55 -- 64 
                \item[6.] 65 -- 74 
                \item[7.] \hspace{\parindent} $\geq$ 75
            \end{itemize} \\ 

            \midrule
            Individual Income & cen\_ind\_grpd\_personal\_inc\_code & This variable captures the total before-tax personal income of an individual. & 
            \textbf{personal\_income}: 
            \begin{itemize}
                \item[1.] \$5,000 or Less 
                \item[2.] \$5,001 -- \$10,000 
                \item[3.] \$10,001 -- \$20,000 
                \item[4.] \$20,001 -- \$30,000 
                \item[5.] \$30,001 -- \$40,000 
                \item[6.] \$50,001 or More 
                \item[9.] Not Stated
            \end{itemize} \\

            \midrule
            Household Income & cen\_hhd\_grpd\_hhld\_inc\_code & This variable captures the total income for a household, derived by taking the sum of the median individual income of all members whom reside together and share facilities in a private dwelling. & \textbf{household\_income}: 
            \begin{itemize}
                \item[1.] \$20,000 or Less 
                \item[2.] \$20,001 -- \$30,000  
                \item[3.] \$30,001 -- \$50,000 
                \item[4.] \$50,001 -- \$70,000 
                \item[5.] \$70,001 --\$100,000 
                \item[6.] \$100,001 or More 
                \item[9.] Not Stated
            \end{itemize} \\
            \bottomrule
        \end{longtabu}
        %\hspace*{-1cm}
    \end{center}
\end{document}

相关内容