5

Newby here. I found a great template for technical reports here . .

http://www.latextemplates.com/template/stylish-article

enter image description here

I would like to change the background color of the abstract and section headings to a vertical gradient.

The relevant section of code in the template appears to be here . .

\renewcommand{\@maketitle}{%
\twocolumn[{%
\thispagestyle{empty}%    

\vskip-36pt%
{\raggedleft\small\sffamily\bfseries\@JournalInfo\\\@Archive\par}%
\vskip20pt%
{\raggedright\color{color1}\sffamily\bfseries\fontsize{20}{25}\selectfont \@PaperTitle\par}%
\vskip10pt%
{\raggedright\color{color1}\sffamily\fontsize{12}{16}\selectfont  \@Authors\par}%

\vskip18pt%
\fcolorbox{color1}{white}{%
\parbox{\textwidth-2\fboxsep-2\fboxrule}{\centering%

% HERE IS THE SECTION I WANT TO CHANGE
\colorbox{Color2!10}{%

\parbox{\textwidth-4\fboxsep-2\fboxrule}{%
\ifx\@Keywords\@empty%
\sffamily\textbf{\abstractname}\\\@Abstract%
\else%
\sffamily\textbf{\abstractname}\\\@Abstract\\[4pt]%
\textbf{\keywordname}\\\@Keywords%
\fi%
}%
}%

Can anyone guide me in the right direction?

  • 1
    Try with tikz – skpblack Aug 5 '14 at 16:13
  • This is possible with tcolorbox package. And welcome to TeX.SX! – user31729 Aug 5 '14 at 16:22
  • 1
    It's probably easiest to do this by converting the \colorbox commands into tcolorbox environments, which accept TikZ drawing commands as styling options. Refer to Section 7.1 of the manual, particularly the /tcb/interior style key. – Paul Gessler Aug 5 '14 at 16:23
10

One option using the tcolorbox package to define a color box with a vertical shading; since the class uses titlesec to format the titles, the necessary redefinition for sections is quite simple

\titleformat{\section}
  {\large\sffamily\bfseries\filcenter}
  {}
  {0em}
  {\begin{mybox}[center upper,colupper=color1]\arabic{section}.~#1\end{mybox}}
  []
\titleformat{name=\section,numberless}
  {\large\sffamily\bfseries\filcenter}
  {}
  {0em}
  {\begin{mybox}[center upper,colupper=color1]#1\end{mybox}}
  []

where mybox is the newly defined box; a redefinition of \maketitle is also required to use the shading for the box.

Change the colors for the shading (inside the \fill in the definition of mybox) according to your liking:

\documentclass[fleqn,10pt]{SelfArx}
\usepackage[nopar]{lipsum}
\usepackage[many]{tcolorbox}

\setlength{\columnsep}{0.55cm}
\setlength{\fboxrule}{0.75pt}

\definecolor{color1}{RGB}{0,0,90} % Color of the article title and sections
\definecolor{color2}{RGB}{0,20,20} % Color of the boxes behind the abstract and headings

\usepackage{hyperref}
\hypersetup{hidelinks,colorlinks,breaklinks=true,urlcolor=color2,citecolor=color1,linkcolor=color1,bookmarksopen=false,pdftitle={Title},pdfauthor={Author}}

\JournalInfo{Journal, Vol. XXI, No. 1, 1-5, 2013}
\Archive{Additional note}

\PaperTitle{Article Title}

\Authors{John Smith\textsuperscript{1}*, James Smith\textsuperscript{2}}
\affiliation{\textsuperscript{1}\textit{Department of Biology, University of Examples, London, United Kingdom}}
\affiliation{\textsuperscript{2}\textit{Department of Chemistry, University of Examples, London, United Kingdom}}
\affiliation{*\textbf{Corresponding author}: john@smith.com}

\Keywords{Keyword1 --- Keyword2 --- Keyword3}
\newcommand{\keywordname}{Keywords}

\Abstract{\lipsum[1]}

\newtcolorbox{mybox}[1][]{
  freelance,
  frame code={},
  interior code={
    \fill[top color=color2!45,bottom color=color2!5,middle color=color2!15]
      (interior.north west) rectangle (interior.south east);
  }
  outer arc=0pt,
  arc=0pt,
  boxrule=0pt,
  nobeforeafter,
  left=0pt,
  right=0pt,
  top=0pt,bottom=0pt,
  #1
}

\titleformat{\section}
  {\large\sffamily\bfseries\filcenter}
  {}
  {0em}
  {\begin{mybox}[center upper,colupper=color1]\arabic{section}.~#1\end{mybox}}
  []
\titleformat{name=\section,numberless}
  {\large\sffamily\bfseries\filcenter}
  {}
  {0em}
  {\begin{mybox}[center upper,colupper=color1]#1\end{mybox}}
  []

\makeatletter
\renewcommand{\@maketitle}{%
\twocolumn[{%
\thispagestyle{empty}%
\vskip-36pt%
{\raggedleft\small\sffamily\bfseries\@JournalInfo\\\@Archive\par}%
\vskip20pt%
{\raggedright\color{color1}\sffamily\bfseries\fontsize{20}{25}\selectfont \@PaperTitle\par}%
\vskip10pt%
{\raggedright\color{color1}\sffamily\fontsize{12}{16}\selectfont  \@Authors\par}%
\vskip18pt%
\fcolorbox{color1}{white}{%
\parbox{\textwidth-2\fboxsep-2\fboxrule}{\centering%
\begin{mybox}
\ifx\@Keywords\@empty%
\sffamily\textbf{\abstractname}\\\@Abstract%
\else%
\sffamily\textbf{\abstractname}\\\@Abstract\\[4pt]%
\textbf{\keywordname}\\\@Keywords%
\fi%
\end{mybox}
\vskip4pt%
\begingroup%
\raggedright\sffamily\small%
\footnotesize\@affiliation\par%
\endgroup%%
}%
}%
\vskip25pt%
}]%
}%
\makeatother

\begin{document}

\flushbottom
\maketitle
%\tableofcontents
%\thispagestyle{empty}

\section*{Introduction}

%\addcontentsline{toc}{section}{Introduction}

\lipsum[1-3]
 and some mathematics $\cos\pi=-1$ and $\alpha$ in the text\footnote{And some mathematics $\cos\pi=-1$ and $\alpha$ in the text.}.

\section{Methods}

\lipsum[4]

\end{document}

enter image description here

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.