答案1
正如 leandris 提到的,您可以使用tcolorbox
。
\documentclass{book}
\usepackage[most]{tcolorbox}
\newtcolorbox[auto counter]{examquestion}[1][]{colback=white, colframe=black,
fonttitle=\bfseries\sffamily, colbacktitle=white,
enhanced,coltitle=black,top=4mm,
attach boxed title to top center={xshift=-4cm,yshift=-3mm},
title=QUESTION \thetcbcounter,#1}
\begin{document}
\begin{examquestion}
Vrai ou faux?
\end{examquestion}
\begin{examquestion}
Cute or duck?
\end{examquestion}
\end{document}
或者镶嵌盒周围没有框架:
\documentclass{book}
\usepackage[most]{tcolorbox}
\newtcolorbox[auto counter]{examquestion}[1][]{colback=white, colframe=black,
fonttitle=\bfseries\sffamily, colbacktitle=white,
enhanced,coltitle=black,top=4mm,boxed title style={colframe=white},
attach boxed title to top center={xshift=-4cm,yshift=-3mm},
title=QUESTION \thetcbcounter,#1}
\begin{document}
\begin{examquestion}
Vrai ou faux?
\end{examquestion}
\begin{examquestion}
Cute or duck?
\end{examquestion}
\end{document}
答案2
此外薛定谔的猫的前身答案,这是我的稍有不同的版本tcolorbox
:
\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcolorbox[auto counter]{mybox}{lower separated=true,
boxrule=0.5pt,
colback=white,
colframe=black,
coltitle=black,
enhanced,
sharp corners,
halign=center,
boxed title style={colframe=white,colback=white,left=0pt,right=0pt},
attach boxed title to top left={xshift=0.25cm,yshift=-3.5mm},
title=\scriptsize\textsc{Question} \thetcbcounter}
\begin{document}
\begin{mybox}
the question text
\end{mybox}
\end{document}