我是新手。我在这里找到了一个很棒的技术报告模板。
http://www.latextemplates.com/template/stylish-article
我想将摘要和章节标题的背景颜色更改为垂直渐变。
模板中的相关代码部分似乎在这里。
\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%
}%
}%
有人能给我指明正确的方向吗?
答案1
一个选项是使用tcolorbox
包定义带有垂直阴影的颜色框;由于该类用于titlesec
格式化标题,因此对各部分进行必要的重新定义非常简单
\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}}
[]
其中mybox
是新定义的框;\maketitle
还需要重新定义才能使用框的阴影。
根据您的喜好更改阴影的颜色(在\fill
的定义内):mybox
\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}: [email protected]}
\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}