具有浅色背景颜色的摘要

具有浅色背景颜色的摘要

有没有办法给摘要添加背景颜色?我尝试了\colorbox\begin{abstract} ... \end{abstract}环境的各种组合,但都没有效果。

我使用当前版本的 TexShop 并采用默认设置。以下是我的序言:

\documentclass[12pt,twocolumn]{amsart}
\usepackage{geometry}                   
\usepackage{graphicx}
\usepackage[superscript]{cite}
\usepackage{amssymb}
\usepackage{upgreek}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{wallpaper}
\usepackage[size=normalsize,format=plain,textfont=sc]{caption}

\bibstyle{alpha}
\geometry{a4paper}                      

\title{some title}
\author{the author}
\date{} % delete this line to display the current date

\begin{document}
\onecolumn
\maketitle

\begin{abstract}

Lorem ipsum dolor sit amet, 

\end{abstract}

\tableofcontents

\twocolumn
\input{1}

\input{2}

\input{3}

\input{4}

\bibliographystyle{plain}
\bibliography{Lit}

\end{document}

答案1

在标准类中,将环境包装在某个适当的元素(例如)中article就足够了;但是,由于您正在使用,因此需要做额外的工作:您需要重新定义环境以使用,例如,环境(来自abstract\colorboxamsartabstractmdframedmdframed包)具有所需的背景颜色;一个小例子:

\documentclass{amsart}
\usepackage{geometry}                   
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate some text

\geometry{a4paper}                      

\makeatletter
\renewenvironment{abstract}{%
  \ifx\maketitle\relax
    \ClassWarning{\@classname}{Abstract should precede
      \protect\maketitle\space in AMS documentclasses; reported}%
  \fi
  \global\setbox\abstractbox=\vtop \bgroup
    \normalfont\Small
    \list{}{\labelwidth\z@
      \leftmargin3pc \rightmargin\leftmargin
      \listparindent\normalparindent \itemindent\z@
      \parsep\z@ \@plus\p@
      \let\fullwidthdisplay\relax
    }%
    \item[]\vskip-\baselineskip
    \begin{mdframed}[backgroundcolor=blue!20,hidealllines=true]
    \item[\hskip\labelsep\scshape\abstractname.]%
}{%
  \end{mdframed}\endlist\egroup
  \ifx\@setabstract\relax \@setabstracta \fi
}
\makeatother

\title{some title}
\author{the author}
\date{} % delete this line to display the current date

\begin{document}

\begin{abstract}
\lipsum[4]
\end{abstract}

\maketitle

\lipsum[2]

\end{document}

在此处输入图片描述

附注:abstract环境必须放置在 \maketitle当使用 时amsart

这是使用该framed包的另一种选择:

\documentclass{amsart}
\usepackage{geometry}                   
\usepackage{xcolor}
\usepackage{framed}
\usepackage{lipsum}% just to generate some text

\geometry{a4paper}                      

\colorlet{shadecolor}{blue!20}

\makeatletter
\renewenvironment{abstract}{%
  \ifx\maketitle\relax
    \ClassWarning{\@classname}{Abstract should precede
      \protect\maketitle\space in AMS documentclasses; reported}%
  \fi
  \global\setbox\abstractbox=\vtop \bgroup\begin{shaded}
    \normalfont\Small
    \list{}{\labelwidth\z@
      \leftmargin3pc \rightmargin\leftmargin
      \listparindent\normalparindent \itemindent\z@
      \parsep\z@ \@plus\p@
      \let\fullwidthdisplay\relax
    }%
   \item[\hskip\labelsep\scshape\abstractname.]%
}{%

\endlist\end{shaded}\egroup
  \ifx\@setabstract\relax \@setabstracta \fi
}
\makeatother

\title{some title}
\author{the author}
\date{} % delete this line to display the current date

\begin{document}

\begin{abstract}
\lipsum[4]
\end{abstract}

\maketitle

\lipsum[2]

\end{document}

答案2

如果您希望颜色框的宽度与文本的宽度相同,则将其放入小页面中

\documentclass{amsart}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{lipsum}
\let\Abstract\abstract
\long\def\abstract{\mdframed[backgroundcolor=blue!20,hidealllines=true]
  \vspace*{-0.5\baselineskip}\Abstract}
\let\endAbstract\endabstract
\def\endabstract{\endAbstract\endmdframed\par\bigskip}

\title{some title}
\author{the author}

\begin{document}
\maketitle
\begin{abstract}
\lipsum[4]
\end{abstract}

\lipsum[2]

\end{document}

在此处输入图片描述

相关内容