将长表左对齐,同时忽略第一列

将长表左对齐,同时忽略第一列

longtable我本质上正在寻找一种左对齐同时忽略第一列的方法。

因此,在 MWE 中,项目LP1S、、LP1E... 将占据页面左边距的空间,并且 3 个字母的代码LEZ、、HIA... 将与边距对齐。

我对 LaTeX 还很陌生,因此非常感谢任何解释。

梅威瑟:

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

当前布局: 当前布局

所需布局: 目标布局

答案1

您可以将最左边的列放在宽度为 0 的框中以隐藏其宽度。然后它将移动到边距中:

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

在此处输入图片描述

相关内容