带有垂直和顶部栏的练习风格

带有垂直和顶部栏的练习风格

请问,我想用或exercise在序言中定义一个环境,如下图所示。mdframedtabularx

在此处输入图片描述

我认为这个环境定理可以解决问题,只需要用白色填充右侧和底部。

 \documentclass{article}
 \usepackage{amssymb}              
\usepackage[framemethod=TikZ]{mdframed} 

\newcounter{ex}%[section] \setcounter{theo}{0}
\newenvironment{ex}[2][]{%
\refstepcounter{ex}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=white]
{\strut \textcolor{red}{Exercice~\theex}};}}
}%
{\mdfsetup{%
frametitle={
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=white]
{\strut \textcolor{red}{Exercice~#1}};}}%
}%
\mdfsetup{innertopmargin=5pt, innerbottommargin=10pt, linecolor=yellow!60!brown!60!,%
linewidth=2.3pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax, roundcorner=5pt
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}

\begin{document}
\begin{ex}{application}
ljlklkj
\end{ex}

\end{document}  

在此处输入图片描述

答案1

尝试这个

\documentclass{article}
 \usepackage{amssymb}              
\usepackage[framemethod=TikZ]{mdframed} 

\newcounter{ex}%[section] \setcounter{theo}{0}
\newenvironment{ex}[2][]{%
\refstepcounter{ex}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=white]
{\strut \textcolor{red}{Exercice~\theex}};}}
}%
{\mdfsetup{%
frametitle={
\tikz[baseline=(current bounding box.east),outer sep=5pt]
\node[anchor=east,rectangle,fill=white]
{\strut \textcolor{red}{Exercice~#1}};}}%
}%
\mdfsetup{innertopmargin=5pt, innerbottommargin=10pt, linecolor=yellow!60!brown!60!,%
linewidth=2.3pt,topline=true,%
rightline=false,%
bottomline=false,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax, roundcorner=0pt
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}

\begin{document}
\begin{ex}{application}
ljlklkj
\end{ex}

\end{document}  

答案2

这只是开始。它取自这个论坛上的一个回复,我不记得是从哪里来的了。谢谢

\documentclass{article}
%\usepackage{fontspec}
\usepackage{mdframed} % Add easy frames to paragraphs
\usepackage{lipsum} % For dummy text
\usepackage{xcolor}
\usepackage{xparse} % Add support for \NewDocumentEnvironment
\definecolor{graylight}{cmyk}{.30,0,0,.67} % define color using xcolor syntax

\newmdenv[ % Define mdframe settings and store as leftrule
  linecolor=graylight,
  linewidth=4pt,
  topline=true,
  bottomline=false,
  rightline=false,
  skipabove=\topsep,
  skipbelow=\topsep
]{leftrule}

\NewDocumentEnvironment{example}{O{\textbf{Example:}}} % Define example environment
{\begin{leftrule}\noindent\textcolor{graylight}{#1}\par}
{\end{leftrule}}

\begin{document}
\begin{example}
\lipsum[1]
\end{example}

\begin{example}[Example]
\lipsum[1]
\end{example}
\end{document}[![enter image description here][1]][1]

在此处输入图片描述

相关内容