0

I'm setting the margin configurations for multiple environments. For instances firstenvironment sets the margins using \setlength, then I make use of the multicols package inside the new environment. The problem is that the text doesn't seem to respect the bottom margin in the first page where the environment is just being used, but the text in the next pages do respect the margins. The same happens when I create a second environment with its own margin configurations. Not sure why the margins are not activated immediately when the environment begins. Any suggestions would be welcome, thanks!

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{showframe} % show the frame margins
\usepackage{multicol}

\newenvironment{firstenvironment}{
    \setlength{\hoffset}{0mm}
    \setlength{\voffset}{0mm}
    \setlength{\headsep}{20pt}
    \setlength{\headheight}{4em}
    \setlength{\textheight}{6in}
    \setlength{\footskip}{10mm}}{}

\newenvironment{secondenvironment}{
    \setlength{\hoffset}{0mm}
    \setlength{\voffset}{0mm}
    \setlength{\headsep}{5pt}
    \setlength{\headheight}{2em}
    \setlength{\textheight}{5in}
    \setlength{\footskip}{20mm}}{}

\begin{document}
\begin{firstenvironment}
\setlength\columnsep{30pt}
\begin{multicols}{2}
        {\Large\bf 1ST LIPSUM}\\
        \lipsum[1-10]
    \end{multicols}
\end{firstenvironment}

\newpage

\begin{secondenvironment}
\begin{multicols}{2}
    {\Large\bf 2ND LIPSUM}\\
    \lipsum[1-10]
\end{multicols}
\end{secondenvironment}

\end{document}

enter image description here

4
  • Welcome to TeX.SE!
    – Mensch
    Commented Oct 20, 2021 at 6:23
  • What is purposes of firstenvironment and secondenvironment? If you not use them in document, multicolumns work fine. These environment (as far as I see) only prevent that multicols can be spread over more pages.
    – Zarko
    Commented Oct 20, 2021 at 6:52
  • unrelated but don't use \bf in latex (it is not defined by default, just in some classes fro compatibility with documents from before 1994) Commented Oct 20, 2021 at 7:05
  • while it is possible to change the page dimensions after a forced page break (see lscape package landscape environment or geometry package \newgeometry) you need to do a lot more than this and reset all the internal parameters, just setting \textheight for example won't change the internal \vsize that is the size tex will actually use for page breaking. It isn't clear what you want these environments to do but perhaps \newgeometry is what you are looking for. Commented Oct 20, 2021 at 7:09

1 Answer 1

0

I just figure out how to fix it. I made use of the package changepage. The idea is to include in the parameters of this command, the differences between the new margins and old margins. There is no need to use environments to set pages with different margins (which considers header, footer and margin notes), but to keep the same structure of the original post, I provide a solution that can be easily compared with.

\documentclass[12pt]{article}
\usepackage[paperheight=11in,paperwidth=8.5in,includeheadfoot]{geometry}
\usepackage{lipsum}
\usepackage{showframe} 
\usepackage{multicol}
\usepackage{changepage}
\usepackage{calc}

\newenvironment{firstenvironment}{}{}
\newenvironment{secondenvironment}{}{}

\begin{document}

\setlength{\textheight}{7in}
\setlength{\headsep}{20pt}
\setlength{\headheight}{4em}
\setlength{\footskip}{10mm}

\begin{firstenvironment}
    \begin{multicols}{2}
        {\Large 1ST LIPSUM}\\
        \lipsum[1-10]
    \end{multicols}
\end{firstenvironment}

\newpage
\changepage{-2in}{}{}{}{}{}{2em-4em}{5pt-20pt}{20mm-10mm}
%\changepage{textheight}{textwidth}{evensidemargin}{oddsidemargin}{columnsep}{topmargin}{headheight}{headsep}{footskip}

\begin{secondenvironment}
    \begin{multicols}{2}
        {\Large 2ND LIPSUM}\\
        \lipsum[1-10]
    \end{multicols}
\end{secondenvironment}

\restoregeometry

\begin{firstenvironment}
    \begin{multicols}{2}
        {\Large 3rd LIPSUM}\\
        \lipsum[1-10]
    \end{multicols}
\end{firstenvironment}

\end{document}
  • The command \changepage considers the following parameters: \changepage{textheight}{textwidth}{evensidemargin}{oddsidemargin}{columnsep}{topmargin}{headheight}{headsep}{footskip}
  • The margins that are left in blank under the \changepage command consider the default margins of the article class. If you want to restore the margins after setting a new one, just use the command \restoregeometry

enter image description here

You must log in to answer this question.

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