带有方形框的示例环境

带有方形框的示例环境

我试图在教科书中的每个示例前添加黑色方块。但是当我使用以下代码时,结果如图所示。

\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored

\usepackage{lipsum} % Inserts dummy text
\usepackage{titlesec}

\usepackage{changepage}
\strictpagecheck
\usepackage{tikz} % Required for drawing custom shapes


\usepackage[english]{babel} % English language/hyphenation

\usepackage{enumitem} % Customize lists
\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists

\usepackage{booktabs} % Required for nicer horizontal rules in tables

\usepackage[many]{tcolorbox}

\usepackage{xcolor} % Required for specifying colors by name
\definecolor{elanblue}{cmyk}{0.67,0.9,0,0} % Define the orange color used for highlighting throughout the book
\definecolor{elanpurple}{cmyk}{0.68,0,1,0} % Define the orange color used for highlighting throughout the book

\newtheorem{exampleT}{Example}[chapter]
\newenvironment{example}{\begin{eBox}\begin{exampleT}}{\hfill{\color{red}\tiny\ensuremath{\blacksquare}}\end{exampleT}\end{eBox}}

\documentclass[[a4paper,12pt,fleqn]{book} % Default font size and left-justified equations

\usepackage[dvipsnames]{xcolor}
\usepackage{shadow}% kotak shadow
\usepackage{exsheets}
%\usepackage[solutions]{mchoice}
\usepackage{enumitem}
\usepackage{xparse}

\begin{document}

\begin{example}
    Which of the following is NOT a set ?
    \hspace*{\fill}\textbf{[NCERT XI]}\\
    (A)\;\; The collection of all boys in the class\hfill\\
    (B)\;\;  The collection of ten most talented writers of India\hfill\\
    (C)\;\;  The collection of all even integers\hfill\\
    (D)\;\; The collection of all months in a year beginning with the letter
    'J'\hfill\\
    Solution : \textbf{B}\\
    Option B is not mathematically well-defined collection of objects and hence not a set.\\ 
    Option A, C, D is a well-defined collection of objects in the sense that we can definitely decide whether a given particular object belongs to a given collection or not.
\end{example}

\end{document}

在此处输入图片描述

答案1

改编罗格朗橙皮书解决您的问题。我已经看到了您的代码和项目。

在此处输入图片描述

\documentclass[a4paper,12pt,fleqn]{book}
    \usepackage{exsheets}
    \usepackage{amssymb}
    \usepackage{enumitem}
    \RequirePackage[framemethod=default]{mdframed}
    \definecolor{elanblue}{cmyk}{0.67,0.9,0,0} 
    \definecolor{elanpurple}{cmyk}{0.68,0,1,0}
\usepackage{newtxtext,newtxmath}
    \newmdenv[skipabove=7pt,
    skipbelow=7pt,
    rightline=false,
    leftline=true,
    topline=false,
    bottomline=false,
    backgroundcolor=elanblue!20,
    linecolor=elanblue,
    innerleftmargin=20pt,
    innerrightmargin=5pt,
    innertopmargin=5pt,
    innerbottommargin=5pt,
    leftmargin=3cm,
    rightmargin=0cm,
    linewidth=4pt]{eBox}
    \newtheorem{exampleT}{Example}[chapter]
    \newenvironment{example}{\begin{eBox}\begin{exampleT}{\hspace{-2.8cm}$\blacksquare$}\hspace{2.4cm}}{\hfill{\color{elanblue!20}\tiny}\end{exampleT}\end{eBox}}


    \begin{document}
        \begin{example} 
        \normalfont The set-builder $\{-2,-1,0,+1\}$
    \begin{itemize}
        \item[(A)] One
        \item[(B)] Two
        \item[(C)] 3rd
    \end{itemize}
    \end{example}
\end{document}

相关内容