6

I was trying to create a custom abstract environment with minipages and adjusted margins. Everything works fine, except for that the right margin changes according to the left. I could'n find solution. Here is the whole code:

\documentclass{article}
\usepackage[a4paper]{geometry}

% Setting character encoding to UFT-8, and loading the babel package
% with Hungarian language.
\usepackage[utf8]{inputenc}
\usepackage[magyar]{babel}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{changepage}


\author{Alap Tibor}
\title{\LaTeX\ gyakorlás}

\newenvironment{myabstract}
{\begin{adjustwidth}{-1cm}{-1cm}
\begin{minipage}{0.3\textwidth}
\vspace{-1cm}
\maketitle
\end{minipage}
\begin{minipage}{0.7\textwidth}
\begin{flushleft}
\textbf{\textit{ABSTRACT}}
\end{flushleft}
\vspace{2mm}
\hrule %{\textwidth}{1.5pt}
\smallskip
\textbf\bgroup}
{\egroup
\vspace{1mm}
\hrule %{\textwidth}{1.5pt}
\end{minipage}
\end{adjustwidth}
\vspace{1cm}}

\begin{document}

\begin{myabstract}
    \lipsum[13]
\end{myabstract}

\begin{multicols}{2}
    \section{Bevezető}
    \lipsum[22-24]
\end{multicols}
\end{document}  

Adjusting the second parameter of \adjustwidth does not make any change. Many thanks for any advice.

  • Why do you set the contents within myabstract's definition inside a minipage? – Werner Dec 10 '13 at 22:47
  • To achieve the layout I wanted to. I am not an expert so there might be better/easier solution. – alaptib Dec 10 '13 at 22:51
  • @alaptib the minipage forces the inner text width to be .7 of the original text block width, so only the left margin can have an effect, the right margin is necessarily the space left over after you have a block of .7\textwidth indented by the left margin. – David Carlisle Dec 10 '13 at 22:56
12

The adjustwidth environment of changepage takes two arguments, both of which are adjustments inward from the existing margins. So,

\begin{adjustwidth}{-1cm}{-1cm}
  % <stuff>
\end{adjustwidth}

will enlarge the text block width around this environment on the left by 1cm, and on the right by 1cm (adding a total of 2cm to the entire text width). However, the actual length that is adjusted is \linewidth, not \textwidth. As such, your references to 0.3\textwidth and 0.7\textwidth is using an incorrect length; it should be 0.3\linewidth and 0.7\linewidth (and there should be a spurious space removed.

Here's a MWE using your definitions with the above incorporated (including an inward adjustment with adjustwidth):

enter image description here

\documentclass{article}
\usepackage[a4paper]{geometry}

\usepackage{lipsum}
\usepackage{multicol}
\usepackage{changepage}


\author{Alap Tibor}
\title{\LaTeX\ gyakorlás}

\newenvironment{myabstract}
{\begin{adjustwidth}{1cm}{1cm}
\begin{minipage}{0.3\linewidth}
\vspace{-1cm}
\maketitle
\end{minipage}%
\begin{minipage}{0.7\linewidth}
\begin{flushleft}
\textbf{\textit{ABSTRACT}}
\end{flushleft}
\vspace{2mm}
\hrule %{\textwidth}{1.5pt}
\smallskip
\textbf\bgroup}
{\egroup
\vspace{1mm}
\hrule %{\textwidth}{1.5pt}
\end{minipage}
\end{adjustwidth}
\vspace{1cm}}

\begin{document}

\begin{myabstract}
    \lipsum[13]
\end{myabstract}

\begin{multicols}{2}
    \section{Bevezető}
    \lipsum[22-24]
\end{multicols}
\end{document} 

As reference in terms of the lengths, see Difference between \textwidth, \linewidth and \hsize.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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