Adding Background color to Columns

This question already has an answer here:

  • Shaded Multicols 1 answer

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. Adding Background color to Columns

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:[email protected]}{[email protected]} \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} 

Replay

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:[email protected]}{[email protected]}
\vspace{-5mm}
}
\date{}

\makeatletter
\let\[email protected]@sofar\[email protected]
\let\[email protected]\box
\let\[email protected]\rlap
\def\[email protected]{%
\let\box\colorcolumn
\def\rlap{\let\box\[email protected]\[email protected]}%
\[email protected]@sofar
}
\def\colorcolumn#1{%
       \kern\dimexpr-\fboxrule-\fboxsep\relax
        {\let\box\[email protected]\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. Adding Background color to Columns

Category: color Time: 2014-04-15 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.221 (s). 12 q(s)