Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I’m trying to find a way of being able to modify all of the margins of a page whenever I want to and as many times as I want to on a single page in order to be able to put text very easily where I want on a page.

I have thought of using the geometry package and using

 \newgeometry{left=6.75cm, right=1cm, top=1cm, bottom=1cm}
 %…
 \restoregeometry

but unfortunately this only works for whole pages, so I can only change the margins once per page (and then they are valid for the whole page without having the possibility of changing them again).

I found the following script on the internet which enables users to change margins on the fly, just as I want to. The code below works fine and enables me to change the left and right margins of my page as many times as I want to, but unfortunately, it doesn’t give me the option of changing the top and bottom margins.

% placed before \begin{document}

\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
}%
\item[]}
{\end{list}}

% And then inside the document, whenever I want to use
% the command to change the margins on the current page

\begin{changemargin}{1.9875cm}{-3.7625cm}
% this means the left margin increases by 1.9875cm compared
% to the default left margin (4.7625cm) (so left margin=6.75cm here)
% and the right margin decreases by 3.7625cm (so right margin=1cm)

% ... (text or pictures in new environment)

\end{changemargin}

For this reason, I tried to adapt the code above and came up with the code below:

% placed before \begin{document}
\newenvironment{changemargin}[3]{%
\begin{list}{}{%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\topmargin}{#3}%
}%
\item[]}
{\end{list}}

% And then to use the command:
\begin{changemargin}{1.9875cm}{-3.7625cm}{1cm}
% ...
\end{changemargin}

It compiles and still changes the left and right margins but the top margin remains unchanged. (I haven’t yet tried to change the bottom margin).

Can anyone help me get this code to work completely, and enable me to modify the left, right, top and bottom margins of a page? Thanks.

share|improve this question
    
@Percy If you want to place text arbitrarily on a page, I suggest you see if the package textpos can satisfy your needs. The command \enlargethispage{<a dimension>} enlarge the page with a given number or lines, points, centimetres etc. –  Sveinung Aug 26 '12 at 13:46
    
Did you try to use minipage? –  Sigur Aug 26 '12 at 14:17

2 Answers 2

Just for the sake of completeness: with a KOMA class you can produce the same weird results with KOMA-Scripts own addmargin environment.

I took the liberty to take Gonzalo Medina's example and adjust it for scrartcl:

\documentclass{scrartcl}
\usepackage[paperheight=18cm]{geometry}
\usepackage{lipsum}

\begin{document}
\lipsum[1-3]
\newpage
\newgeometry{top=0.5cm, bottom=0.5cm}
\begin{addmargin}[-2cm]{-1cm}
\lipsum[4]
\end{addmargin}
\lipsum[1]
\begin{addmargin}[1cm]{2cm}
\lipsum[3]
\end{addmargin}
\lipsum[4]
\newpage
\restoregeometry
\lipsum[1-3]
\newpage
\newgeometry{top=2.5cm, bottom=2.5cm}
\begin{addmargin}[2cm]{2cm}
\lipsum[4]
\end{addmargin}
\lipsum[4]
\begin{addmargin}[3cm]{-3cm}
\lipsum[3]
\end{addmargin}

\end{document}

Since the output looks nearly the same I don't provide a picture.

share|improve this answer

You can use a combination of geometry (to change the top and bottom margings) and the adjustwidth environment provided by the changepage package (this uses internally a list and it's similar to your changemargin environment):

\documentclass{article}
\usepackage[paperheight=14cm]{geometry}
\usepackage{changepage}
\usepackage{lipsum}

\begin{document}
\lipsum[1-3]
\newpage
\newgeometry{top=0.5cm, bottom=0.5cm}
\begin{adjustwidth}{-2cm}{-1cm}
\lipsum[4]
\end{adjustwidth}
\lipsum[1]
\begin{adjustwidth}{1cm}{2cm}
\lipsum[3]
\end{adjustwidth}
\lipsum[4]
\newpage
\restoregeometry
\lipsum[1-3]
\newpage
\newgeometry{top=2.5cm, bottom=2.5cm}
\begin{adjustwidth}{2cm}{2cm}
\lipsum[4]
\end{adjustwidth}
\lipsum[4]
\begin{adjustwidth}{3cm}{-3cm}
\lipsum[3]
\end{adjustwidth}

\end{document}

enter image description here

I strongly suggest you, as a personal opinion, not to do this.

share|improve this answer
2  
Hear hear!!.... –  percusse Aug 26 '12 at 15:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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