有人知道如何设置框架元素的背景颜色吗?
\begin{framed}
Let me have a background :(
\end{framed}
答案1
如果使用以下包,定义背景颜色非常容易mdframed
:
\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}
\begin{document}
test
\begin{mdframed}[backgroundcolor=blue!20]
In any right triangle, the area of the square whose side is the hypotenuse is equal to the sum of the areas of the squares whose sides are the two legs.
\end{mdframed}
\end{document}
答案2
这包装文档是你的朋友。
\documentclass{article}
\usepackage{xcolor}
\usepackage{framed}
\definecolor{shadecolor}{rgb}{1,0,0}
\begin{document}
\begin{shaded*}
Let me have a background :(
\end{shaded*}
\end{document}
答案3
framed
带有 aframeborder
和 a 的包的两个解决方案framecolor
:我定义了frshaded
和frshaded*
环境。可以轻松更改规则厚度和文本与框架之间的距离。
\documentclass [a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[x11names]{xcolor}
\usepackage{framed}
\colorlet{shadecolor}{LavenderBlush2}
\colorlet{framecolor}{Red1}
\usepackage{lipsum}
\newenvironment{frshaded}{%
\def\FrameCommand{\fboxrule=\FrameRule\fboxsep=\FrameSep \fcolorbox{framecolor}{shadecolor}}%
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}
\newenvironment{frshaded*}{%
\def\FrameCommand{\fboxrule=\FrameRule\fboxsep=\FrameSep \fcolorbox{framecolor}{shadecolor}}%
\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\begin{document}
Text text text text text text text text text text text text text text text text text text text text. text text text text text
\begin{frshaded}
\lipsum[1-2]
\end{frshaded}
\colorlet{framecolor}{VioletRed4}
\setlength\FrameRule{1.5pt}
\begin{frshaded*}
\lipsum[1-2]
\end{frshaded*}
\end{document}