答案1
在下面的 MWE 中,我tcolorbox
为左上角的文本使用了新定义的符号。符号包含在fontawesome5
包中,可以通过访问\faToggleOn
。文本周围的间距、框的高度、宽度和颜色当然可以根据您的需要进行调整。
为了摆脱外框的框架,我使用了boxrule=0pt, frame hidden
,为了获得具有 90° 角而不是圆角的角,我添加了sharp corners
。
\documentclass{article}
\usepackage{amssymb}
\usepackage{fontawesome5}
\usepackage[most]{tcolorbox}
\definecolor{mycolor}{RGB}{0,128,128}
\newtcbox{\mybox}{on line,
colback=mycolor,
fontupper=\bfseries\color{white},
boxrule=0pt,
arc=5pt,
boxsep=0pt,
left=2pt,
right=2pt,
top=5pt,
bottom=5pt}
\begin{document}
\begin{tcolorbox}[boxrule=0pt, frame hidden, sharp corners]
\mybox{\faToggleOn\; Câu 3}
Cho $x,y,z$ thỏa mãn $x^2+y^2+z^2=1.$ Chứng minh rằng
\[\dfrac{x^2}{1+2yz}+\dfrac{y^2}{1+2zx}+\dfrac{z^2}{1+2xy}\geqslant \dfrac{3}{5}\]
\end{tcolorbox}
\end{document}
更新版本可自动对框内的框进行编号\section
:
\documentclass{article}
\usepackage{amssymb}
\usepackage{fontawesome5}
\usepackage[most]{tcolorbox}
\definecolor{mycolor}{RGB}{0,128,128}
\newtcbtheorem[auto counter, number within=section,]{mycau}{\faToggleOn\; Câu}%
{enhanced jigsaw,%
sharp corners,%
boxrule=0pt,
frame hidden,%
colbacktitle= mycolor,
boxed title style={boxrule=0pt,
frame hidden,
boxsep=0pt,
top=5pt,
bottom=5pt,
left=2pt,
right=2pt,
arc=5pt},
attach boxed title to top left={xshift=0.5cm,yshift=-8mm},
fonttitle=\color{white}\bfseries,%
before upper=\hspace{2.5cm}
}{th}
\begin{document}
\begin{mycau}{}{label}
Cho $x,y,z$ thỏa mãn $x^2+y^2+z^2=1.$ Chứng minh rằng
\[\frac{x^2}{1+2yz}+\frac{y^2}{1+2zx}+\frac{z^2}{1+2xy}\geqslant \frac{3}{5}\]
\end{mycau}
\end{document}
答案2
该xcolor
包由包自动加载tcolorbox
,提供了宏\colorbox
和\textcolor
;它们在这里派上用场了。
\documentclass{article}
\usepackage[vietnamese]{babel}
\usepackage{amsmath,amssymb,tcolorbox,fontawesome5}
% optional: load suitable text and math fonts:
\usepackage{unicode-math}
\setmainfont{Fira Sans}
\setmathfont{Fira Math Regular}[Scale=MatchLowercase]
\begin{document}
\begin{tcolorbox}[boxrule=0pt]
\colorbox{teal}{\textcolor{white}{\bfseries\faToggleOn\ Câu 3}}
Cho $x,y,z$ thỏa mãn $x^2+y^2+z^2=1.$ Chứng minh rằng
\[
\frac{x^2}{1+2yz}+\frac{y^2}{1+2zx}+\frac{z^2}{1+2xy} \geqslant \frac{3}{5}
\]
\end{tcolorbox}
\end{document}
答案3
受到@leandriis 和@Mico 的回答的启发,你可以将以下方法tcolorbox
与以下锻炼包结合起来xsim
:
\documentclass{article}
\usepackage[vietnamese]{babel}
\usepackage[T1]{fontenc}
\usepackage[margin=2cm]{geometry}
\usepackage{amssymb}
\usepackage{fontawesome}
\usepackage[most]{tcolorbox}
\usepackage{xsim}
\DeclareExerciseEnvironmentTemplate{custom}{%
\begin{tcolorbox}[boxrule = 0pt]
\tcbox[on line,colback=teal,colframe=teal,coltext=white,size=small]{%
\faToggleOn\sffamily\bfseries\
\XSIMmixedcase{\GetExerciseName}
\GetExerciseProperty{counter}%
}\quad
}{\hfill\textbf{Điện Biên}\end{tcolorbox}}
\xsimsetup{
exercise/template = custom ,
exercise/name = Câu
}
\begin{document}
\begin{exercise}
Cho $x,y,z$ thỏa mãn $x^2+y^2+z^2=1$. Chứng minh rằng
\[ \frac{x^2}{1+2yz}+\frac{y^2}{1+2zx}+\frac{z^2}{1+2xy} \geqslant \frac{3}{5} \]
\end{exercise}
\end{document}