2

I have a Document in two column mode. As the document is a kind of form, I want to fill the end of the document with textbox for additional remarks. Idealy I would move that textbox to the next page if there is not enough space available.

If floats are the wrong environment but something else is, feel free to let me know.

I have attached a previous version of the document that illustrates the idea but used the multicols environmentexample

M(N)WE

\documentclass[a4paper]{article}

\usepackage{xcolor}
\usepackage{float}
\usepackage{tabularray}

\DefTblrTemplate{contfoot-text}{default}{}
\DefTblrTemplate{conthead-text}{default}{}
\DefTblrTemplate{caption}{default}{}
\DefTblrTemplate{conthead}{default}{}
\DefTblrTemplate{capcont}{default}{}


\usepackage[left=1.2cm,right=1.7cm,top=1cm,bottom=1.8cm]{geometry}

\begin{document}

\twocolumn

\begin{longtblr}{
    colspec = {Q[c!,white]Q[c!,white]Q[l,white]},
    hlines, vlines,
    rowhead=1,
    }

    \textbf{Ist} & \textbf{Soll} & \textbf{Bezeichnung} \\\hline
    \SetCell[c=3]{l}\textbf{Modul 1}                    \\*
                 & 1             & A                    \\*
                 & 2             & B                    \\*
                 & 3             & C                    \\*
                 & 4             & D                    \\*
                 & 5             & E                    \\*
                 & 6             & F                    \\\pagebreak
    \SetCell[c=3]{l}{\textbf{Modul 2}}                  \\*
                 & 1             & A                    \\*
                 & 2             & B                    \\*
                 & 3             & C                    \\*
                 & 4             & D                    \\*
                 & 5             & E                    \\*
                 & 6             & F                    \\
\end{longtblr}

\hspace{-10cm}\begin{figure}[H]

    \textsc{Anmerkungen:}

    \vspace{0.5cm}

    \setlength{\fboxsep}{1pt}
    \fbox{\parbox[c][8cm][c]{0.9\textwidth}{\hfill}}
\end{figure}

\end{document}
3
  • Actually, the easiest solution would be to use \onecolumn\begin{multicols}{2}... on the last page. There is an automatic \clearpage with \onecolumn. Commented Jun 12 at 14:39
  • Thats right. I should have specified, that I cant use multicols as breaking longtblr does not work properly. I don’t necessarily need to switch back to onecolumn if that helps in any way
    – N0W0RK
    Commented Jun 12 at 15:01
  • Longtblr does make all the difference. An MWE would be nice. There are other options, but I would just overlap the bottom of the page and hope for the best. Commented Jun 12 at 15:15

1 Answer 1

1

This shows one way to overlap the bottom of the page.

AFAIK, there is no way to tell is both columns will fit above the overlay. The right column, yes, but moving to the next page would also move you into the left column, requiring a different overlay.

\documentclass[a4paper]{article}

\usepackage{xcolor}
\usepackage{float}
\usepackage{tabularray}

\DefTblrTemplate{contfoot-text}{default}{}
\DefTblrTemplate{conthead-text}{default}{}
\DefTblrTemplate{caption}{default}{}
\DefTblrTemplate{conthead}{default}{}
\DefTblrTemplate{capcont}{default}{}


\usepackage[left=1.2cm,right=1.7cm,top=1cm,bottom=1.8cm]{geometry}

\begin{document}

\twocolumn

\begin{longtblr}{
    colspec = {Q[c!,white]Q[c!,white]Q[l,white]},
    hlines, vlines,
    rowhead=1,
    }

    \textbf{Ist} & \textbf{Soll} & \textbf{Bezeichnung} \\\hline
    \SetCell[c=3]{l}\textbf{Modul 1}                    \\*
                 & 1             & A                    \\*
                 & 2             & B                    \\*
                 & 3             & C                    \\*
                 & 4             & D                    \\*
                 & 5             & E                    \\*
                 & 6             & F                    \\\pagebreak
    \SetCell[c=3]{l}{\textbf{Modul 2}}                  \\*
                 & 1             & A                    \\*
                 & 2             & B                    \\*
                 & 3             & C                    \\*
                 & 4             & D                    \\*
                 & 5             & E                    \\*
                 & 6             & F                    \\
\end{longtblr}
   

\setlength{\fboxsep}{1pt}
\csname if@firstcolumn\endcsname \newpage \fi% must be in second column
\vspace*{\fill}\hspace*{\fill}% lower right corner of page
\llap{\raisebox{\depth}[0pt][0pt]{\begin{minipage}{\textwidth}% oyter boc
  \textsc{Anmerkungen:}

  \vspace{0.5cm}%
  \fbox{\parbox[c][8cm][c]{\dimexpr \textwidth-2\fboxsep-2\fboxrule}{\hfill}}
\end{minipage}}}

\end{document}

This version can handle being bumped to the next page. There were a couple of unexpected problems. The columns were being reset too soon for \protected@write. It seems that \twocolumn produces an extra \afterpage. Second, when the figure is moved to the last page, it is converted to a [p] figure and wound up centered (see \@fptop).

\documentclass[a4paper]{article}

\usepackage{xcolor}
\usepackage{float}
\usepackage{tabularray}

\DefTblrTemplate{contfoot-text}{default}{}
\DefTblrTemplate{conthead-text}{default}{}
\DefTblrTemplate{caption}{default}{}
\DefTblrTemplate{conthead}{default}{}
\DefTblrTemplate{capcont}{default}{}

\usepackage[left=1.2cm,right=1.7cm,top=1cm,bottom=1.8cm]{geometry}

\usepackage{afterpage}
\newcounter{colno}[page]
\newcommand{\stepcolumn}{\stepcounter{colno}\afterpage{\stepcolumn}}
\AtEndDocument{\global\let\stepcolumn\relax}
\stepcolumn

\newcounter{checkcolno}
\newcommand{\ColumnNumber}{}%reserve global name
\makeatletter
\newcommand{\CheckColumnNumber}{\stepcounter{checkcolno}%
  \protected@write{\@auxout}{\let\thecolno=\relax}%
    {\string\newcolno{\thecheckcolno}{\thecolno}}%
  \@ifundefined{@colno\thecheckcolno}{\edef\ColumnNumber{\thecolno}}%
    {\edef\ColumnNumber{\csname @colno\thecheckcolno\endcsname}}%
}
\newcommand{\newcolno}[2]{\expandafter\gdef\csname @colno#1\endcsname{#2}}
\makeatother

\begin{document}

\twocolumn\setcounter{colno}{1}% extra \afterpage

\begin{longtblr}{
    colspec = {Q[c!,white]Q[c!,white]Q[l,white]},
    hlines, vlines,
    rowhead=1,
    }

    \textbf{Ist} & \textbf{Soll} & \textbf{Bezeichnung} \\\hline
    \SetCell[c=3]{l}\textbf{Modul 1}                    \\*
                 & 1             & A                    \\*
                 & 2             & B                    \\*
                 & 3             & C                    \\*
                 & 4             & D                    \\*
                 & 5             & E                    \\*
                 & 6             & F                    \\\pagebreak
    \SetCell[c=3]{l}{\textbf{Modul 2}}                  \\*
                 & 1             & A                    \\*
                 & 2             & B                    \\*
                 & 3             & C                    \\*
                 & 4             & D                    \\*
                 & 5             & E                    \\*
                 & 6             & F                    \\
\end{longtblr}

%\noindent\rule{1pt}{14cm}
   
\vfill
\begin{figure}[ht]
  \setlength{\fboxsep}{1pt}%
  \CheckColumnNumber
  \ifnum\ColumnNumber=2\relax% overlap left column
    \hspace*{-\columnwidth}\hskip-\columnsep
  \fi
  \begin{minipage}{\textwidth}% oyter boc
    \textsc{Anmerkungen:}

    \vspace{0.5cm}%
    \fbox{\parbox[c][8cm][c]{\dimexpr \textwidth-2\fboxsep-2\fboxrule}{\hfill}}
  \end{minipage}%
  \ifnum\ColumnNumber=1\relax% overlap right column
    \hskip-\columnwidth\hskip-\columnsep
    \global\csname @fptop\endcsname=0pt% do not center float page
  \fi
\end{figure}

\end{document}
1
  • I have added an MWE in my original post. When compiling this, the minipage fully overlaps with the text in the two columns
    – N0W0RK
    Commented Jun 12 at 17:44

You must log in to answer this question.

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