0

I'm new to LateX and really struggling to get around the page margins.

So I've been given a default template (I've made a few adjustments to preamble and packages) to write my dissertation by the department which limits the page margins by a lot, but I'm trying to get my longtable to ignore these margins. I've tried \setlength\LTleft{-1cm} and \hspace*{-1cm} but it's just not co-operating. Another issue is that the table has alternating margins between different pages which I'm really confused about.

How do I make a long table with custom margins of -1cm on the right/left, or alternatively how do I reduce the table size to fit inside the pre-determined margins?

Thanks everyone for any help you can provide :)

E.g. enter image description here

and

enter image description here

Heres all my preamble:

\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}

And here's some of my chapter2/longtable code:

\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}
  • Make your table content smaller, so it fits the page. Also your post does not include a question. – Henri Menke Sep 24 '18 at 3:28
  • Hey @HenriMenke so the problem with reducing table size {longtable}{L{3cm} L{3cm} L{4.5cm} L{4cm}} is that my variable codes (e.g. cen_ind_grpd_personal_inc_code) won't fit in the cell and overwrites the next column. Would you happen to know how I can fix this? – Lucas Sep 24 '18 at 3:39
  • 1
    You could rotate them 90° using \rotatebox from the graphicx package. – Henri Menke Sep 24 '18 at 3:56
  • Obviously one can make the third column L{5.5cm} smaller. The fourth column might be smaller if you replaced the itemize with a tabular – John Kormylo Sep 24 '18 at 15:02
1

A fast option what can I offer is using lontabu, that is an extension of longtable in the tabu package, you could control the dimmension of the cells using to \linewidth in a proportional dimension distribution factor(pddf) { X[pddf] X[pddf] X[pddf] X[pddf]}, in this case...

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

Means that line width is distributed in proportionally. means that \linewidth = 0.4X+1.5X+X+X.

For the pages issue, the book documentclass default is for two side pages, if your printed document is only for one page just put the option oneside: \documentclass[11pt,oneside]{book}

RESULT: enter image description here

MWE:

% 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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.