1

I'm essentially looking for a way to align a longtable left while ignoring the first column.

So in the MWE the items LP1S, LP1E, ... would occupy space in the left margin of the page and the 3-letter codes LEZ, HIA, ... would be aligned to the margin.

I'm entirely new to LaTeX so any and all explanation is appreciated.

MWE:

\documentclass[12pt,a4paper,final]{article}

\usepackage[utf8]{inputenc}
\usepackage[dutch]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{textcomp}

\usepackage{changepage}
\usepackage{longtable}

\title{SOCS Oefeningen}
\author{}
\date{}

\begin{document}
\maketitle

\begin{flushleft}    
\begin{longtable}[l]{r l l r | l}
&&&& \textbf{geheugenreservaties:} \\
&&&& n \textrightarrow{} R1 \\
&&&& deler \textrightarrow{} R2 \\
&&&& n / 2 \textrightarrow{} R3 \\
&&&& getal \% deler \textrightarrow{} R4 \\
&&&& getal in geheugen \\
&&&& mult in geheugen \\

        & LEZ   &           &           & \\
        & HIA   & R1        & R0        & n = getint() \\
        & HIA.w & R0        & 1         & \\
        & DRU & & & \\
        & HIA.w & R0        & -1        & \\
        & DRU & & & \\
        & HIA.w & R2        & 2         & deler = 2 \\
        & HIA   & R3        & R1        & R3 = n \\
        & DEL.w & R3        & 2         & R3 = n / 2 \\
LP1S:   & VGL   & R2        & R3        & eerste while loop \\
        & VSP   & GR        & LP1E      & spring indien deler $>$ (n / 2) \\
        & HIA.w & R0        & 0         & \\
        & BIG   & R0        & mult      & mult = 0 \\
        & HIA   & R0        & R1        & \\
        & BIG   & R0        & getal     & getal = n \\
LP2S:   & HIA   & R4        & R0        & tweede while loop, R4 = getal \\
        & MOD   & R4        & R2        & R4 = getal \% deler \\
        & VGL.w & R4        & 0         & \\
        & VSP   & NGEL      & LP2E      & spring indien (getal \% deler) $\neq$ 0 \\
        & HIA   & R0        & mult      & \\
        & OPT.w & R0        & 1         & mult++ \\
        & BIG   & R0        & mult      & \\
        & HIA   & R0        & getal     & \\
        & DEL   & R0        & R2        & R0 = getal / deler \\
        & BIG   & R0        & getal     & getal = getal / deler \\
        & SPR   &           & LP2S      & \\
LP2E:   & HIA   & R0        & mult      & R0 = mult \\
LP3S:   & VGL.w & R0        & 0         & if statement \\
        & VSP   & GEL       & LP3E      & spring indien mult $=$ 0 \\
        & HIA   & R0        & R2        & \\
        & DRU & & & \\
        & HIA   & R0        & mult      & \\
        & DRU & & & \\
LP3E:   & OPT.w & R2        & 1         & deler++ \\
        & SPR   &           & LP1S      & \\
LP1E:   & HIA   & R0        & R1        & \\
        & DRU & & & \\
        & HIA.w & R0        & 1         & \\
        & DRU & & & \\
        & STP & & & \\
getal:  & RESGR & & 1 & \\
mult:   & RESGR & & 1 & \\
        & EINDPR & & & \\
\end{longtable}

\end{flushleft}

\end{document}

Current layout: Current layout

Desired layout: Goal layout

0

1 Answer 1

1

You can put the left most column in a box of width 0 to hide its width. It will then move into the margin:

\documentclass[12pt,a4paper,final]{article}

\usepackage[utf8]{inputenc}
\usepackage[dutch]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{collcell}
\usepackage{changepage}
\usepackage{longtable,array}

\title{SOCS Oefeningen}
\author{}
\date{}


\begin{document}
\maketitle

\newcommand\insertcell[1]{\makebox[0pt][r]{#1\hspace{2\tabcolsep}}}

\noindent xxxxxxxxxxxxxxxxxx
\begin{longtable}[l]{@{}>{\collectcell\insertcell}c<{\endcollectcell}@{} l l r | l}
&&&& \textbf{geheugenreservaties:} \\
&&&& n \textrightarrow{} R1 \\
&&&& deler \textrightarrow{} R2 \\
&&&& n / 2 \textrightarrow{} R3 \\
&&&& getal \% deler \textrightarrow{} R4 \\
&&&& getal in geheugen \\
&&&& mult in geheugen \\

        & LEZ   &           &           & \\
        & HIA   & R1        & R0        & n = getint() \\
        & HIA.w & R0        & 1         & \\
        & DRU & & & \\
        & HIA.w & R0        & -1        & \\
        & DRU & & & \\
        & HIA.w & R2        & 2         & deler = 2 \\
        & HIA   & R3        & R1        & R3 = n \\
        & DEL.w & R3        & 2         & R3 = n / 2 \\
LP1S:   & VGL   & R2        & R3        & eerste while loop \\
        & VSP   & GR        & LP1E      & spring indien deler $>$ (n / 2) \\
        & HIA.w & R0        & 0         & \\
        & BIG   & R0        & mult      & mult = 0 \\
        & HIA   & R0        & R1        & \\
        & BIG   & R0        & getal     & getal = n \\
LP2S:   & HIA   & R4        & R0        & tweede while loop, R4 = getal \\
        & MOD   & R4        & R2        & R4 = getal \% deler \\
        & VGL.w & R4        & 0         & \\
        & VSP   & NGEL      & LP2E      & spring indien (getal \% deler) $\neq$ 0 \\
        & HIA   & R0        & mult      & \\
        & OPT.w & R0        & 1         & mult++ \\
        & BIG   & R0        & mult      & \\
        & HIA   & R0        & getal     & \\
        & DEL   & R0        & R2        & R0 = getal / deler \\
        & BIG   & R0        & getal     & getal = getal / deler \\
        & SPR   &           & LP2S      & \\
LP2E:   & HIA   & R0        & mult      & R0 = mult \\
LP3S:   & VGL.w & R0        & 0         & if statement \\
        & VSP   & GEL       & LP3E      & spring indien mult $=$ 0 \\
        & HIA   & R0        & R2        & \\
        & DRU & & & \\
        & HIA   & R0        & mult      & \\
        & DRU & & & \\
LP3E:   & OPT.w & R2        & 1         & deler++ \\
        & SPR   &           & LP1S      & \\
LP1E:   & HIA   & R0        & R1        & \\
        & DRU & & & \\
        & HIA.w & R0        & 1         & \\
        & DRU & & & \\
        & STP & & & \\
getal:  & RESGR & & 1 & \\
mult:   & RESGR & & 1 & \\
        & EINDPR & & & \\
\end{longtable}



\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .