7

I am using a two column article and I want to have a background color for only the columns instead of the entire page. How can I do that ? I am using the following template. I would also like to have a separate background color for the abstract part as well. enter image description here

Code:From this link

\documentclass[twoside]{article}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.05} % Palatino needs more space between lines
\usepackage{microtype}
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry}
\usepackage[font=it]{caption}
\usepackage{paralist}
\usepackage{multicol}
\usepackage{lettrine}
\usepackage{lipsum}


\usepackage{abstract}
    \renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small\itshape}

\usepackage{titlesec}
    \renewcommand\thesection{\Roman{section}}
    \titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{}

\usepackage{fancyhdr}
    \pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[C]{Journal paper template $\bullet$ April 2012 $\bullet$ Vol. XXI, No. 1}
\fancyfoot[RO,LE]{\thepage}

\usepackage{hyperref}
\title{\vspace{-15mm}%
    \fontsize{24pt}{10pt}\selectfont
\textbf{Long Titles Look More Impressive Than Short Ones}
}   

\author{%
\large
\textsc{Jonathan S. Doe}\thanks{Template by \href{http://www.howtotex.com}{howtoTeX.com}} \\[2mm]
\normalsize University of Technology, Delft \\
\normalsize \href{mailto:frits@howtoTeX.com}{frits@howtoTeX.com}
\vspace{-5mm}
}
\date{}

\begin{document}
\maketitle
\thispagestyle{fancy}

\begin{abstract}
\noindent \lipsum[1]
\end{abstract}


\begin{multicols}{2} 
\lipsum[1]

\section{Section title example}
\lipsum[1-2]

\section{One more section}
\lipsum[3-5]

\end{multicols}

\end{document}

1 Answers1

1

Combining answer link and surrounding abstract with colorbox:

\documentclass[twoside]{article}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.05} % Palatino needs more space between lines
\usepackage{microtype}
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry}
\usepackage[font=it]{caption}
\usepackage{paralist}
\usepackage{multicol}
\usepackage{lettrine}
\usepackage{lipsum}
\usepackage{xcolor}

\usepackage{abstract}
    \renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small\itshape}

\usepackage{titlesec}
    \renewcommand\thesection{\Roman{section}}
    \titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{}

\usepackage{fancyhdr}
    \pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[C]{Journal paper template $\bullet$ April 2012 $\bullet$ Vol. XXI, No. 1}
\fancyfoot[RO,LE]{\thepage}

\usepackage{hyperref}
\title{\vspace{-15mm}%
    \fontsize{24pt}{10pt}\selectfont
\textbf{Long Titles Look More Impressive Than Short Ones}
}

\author{%
\large
\textsc{Jonathan S. Doe}\thanks{Template by \href{http://www.howtotex.com}{howtoTeX.com}} \\[2mm]
\normalsize University of Technology, Delft \\
\normalsize \href{mailto:frits@howtoTeX.com}{frits@howtoTeX.com}
\vspace{-5mm}
}
\date{}

\makeatletter
\let\old@page@sofar\page@sofar
\let\old@box\box
\let\old@rlap\rlap
\def\page@sofar{%
\let\box\colorcolumn
\def\rlap{\let\box\old@box\old@rlap}%
\old@page@sofar
}
\def\colorcolumn#1{%
       \kern\dimexpr-\fboxrule-\fboxsep\relax
        {\let\box\old@box\fcolorbox{orange!30}{orange!30}{\box#1\llap{\phantom p}}}%
        \kern\dimexpr-\fboxrule-\fboxsep\relax
}
\makeatother

\begin{document}
\maketitle
\thispagestyle{fancy}

\begin{abstract}
\hspace{-0.7cm}\colorbox{yellow!50}{
\parbox{\linewidth}{
\noindent \lipsum[1]
}
}
\end{abstract}

\begin{multicols}{2} 
\lipsum[1]

\section{Section title example}
\lipsum[1-2]

\section{One more section}
\lipsum[3-5]

\end{multicols}

\end{document}

Note that mdframed solution fails with some kind of overflow. Output of compilation

Tahtisilma
  • 2,396
  • Is there any way to increase the breadth of the colorbox of abstract to align them with the columns. Otherwise it looks a bit sketchy. But thanks for your answer. :) – sm176357 Apr 15 '14 at 12:57
  • @bapnu88 You can change
    \hspace{-0.7cm} to \hspace{-1.51cm} and \parbox{\linewidth} to \parbox{1.125\linewidth}
    – Tahtisilma Apr 15 '14 at 13:05