我想创建定理和引理的框。此外,还有一些定义和示例的命令。所有这些命令都与文档章节相关。到目前为止,我所做的如下所示。
但是,我希望结果是定义 1.1、定理 1.2、示例 1.3、定理 1.4、引理 1.5。我该如何得到它?这是上图的语法。我非常感谢这方面的帮助。
\documentclass[a4paper,11pt]{book}
\usepackage{charter}
\usepackage[indonesian]{babel}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx,amsmath,amssymb,amsthm,amsfonts}
\usepackage{tikz, tkz-euclide}
\usetikzlibrary{calc,through,intersections}
\usepackage{contour}
%\usepackage{amsmath,amssymb}
\usepackage{enumerate}
\usepackage[utf8]{inputenc}
\usepackage[margin=2.5cm]{geometry}
%\usepackage{xcolor}
%\usepackage{graphicx}
\usepackage{capt-of}
%\usepackage{tikz}
%\usepackage[indonesian]{babel}
\usepackage{array,multirow}
%\usepackage{amsmath,amssymb}
\usetikzlibrary{angles}
\usepackage{adjustbox}
\usepackage{epigraph}
\usetikzlibrary{patterns}
\usepackage{systeme}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{mdframed}
\usepackage[symbol]{footmisc}
\usetikzlibrary{calc}
\let \ds \displaystyle
\let \ds \displaystyle
\renewcommand{\baselinestretch}{1.3}
\parindent.9cm
%-----------------------------CHAP SEC etc..
\usepackage[explicit]{titlesec}
\definecolor{titlebgdark}{RGB}{0,163,243}
\definecolor{titlebglight}{RGB}{191,233,251}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}
{}
{20pt}
{%
\begin{tcolorbox}[
enhanced,
colback=black!80,
boxrule=0.25cm,
colframe=gray!80,
arc=0pt,
outer arc=0pt,
leftrule=0pt,
rightrule=0pt,
fontupper=\color{white}\sffamily\bfseries\huge,
enlarge left by=-1in-\hoffset-\oddsidemargin,
enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
width=\paperwidth,
left=1in+\hoffset+\oddsidemargin,
right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
top=0.6cm,
bottom=0.6cm,
overlay={
\node[
fill=black!80,
draw=gray!80,
line width=0.15cm,
inner sep=0pt,
text width=1.7cm,
minimum height=1.7cm,
align=center,
font=\color{white}\sffamily\bfseries\fontsize{30}{36}\selectfont
]
(chapname)
at ([xshift=-4cm]frame.north east)
{\thechapter};
\node[font=\small,anchor=south,inner sep=2pt] at (chapname.north)
{\MakeUppercase\chaptertitlename}; % if using amsbook, this should be \chaptername
}
]
#1
\end{tcolorbox}%
}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\huge\bfseries}
{}
{20pt}
{%
\begin{tcolorbox}[
enhanced,
colback=black!80,
boxrule=0.25cm,
colframe=gray!80,
arc=0pt,
outer arc=0pt,
remember as=title,
leftrule=0pt,
rightrule=0pt,
fontupper=\color{white}\sffamily\bfseries\huge,
enlarge left by=-1in-\hoffset-\oddsidemargin,
enlarge right by=-\paperwidth+1in+\hoffset+\oddsidemargin+\textwidth,
width=\paperwidth,
left=1in+\hoffset+\oddsidemargin,
right=\paperwidth-1in-\hoffset-\oddsidemargin-\textwidth,
top=0.6cm,
bottom=0.6cm,
]
#1
\end{tcolorbox}%
}
\titlespacing*{\chapter}
{0pt}{0pt}{40pt}
\makeatother
\titleformat{\section}
{\bfseries\Large\color{black}}{\thesection.}{.5em}{#1}
\titleformat{\subsection}
{\bfseries\large}{\thesubsection.}{.5em}{#1}
%---------------------------THEOREM STYLE etc..
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage{lmodern}
\newtcolorbox[auto counter, number within=chapter, number freestyle={\noexpand\thechapter.\noexpand\arabic{\tcbcounter}}]{theorem}[2][]{%
colback=white,
enhanced,
attach boxed title to top left = {xshift=0mm,yshift=-.1mm},
toprule=1pt, leftrule = 3pt, bottomrule = 1pt, rightrule =1pt,
arc = 0 mm, sharp corners, colframe=NavyBlue,
colframe=NavyBlue,colbacktitle=NavyBlue,
boxed title style = {frame code = { \fill[NavyBlue] (frame.south west)--(frame.north west)--(frame.north east)--([xshift=3mm]frame.east)--(frame.south east)--cycle;
\draw[line width=.5mm,NavyBlue]([xshift=2mm]frame.north east)--([xshift=5mm]frame.east)--([xshift=2mm]frame.south east);
}
},
breakable,
fonttitle=\sffamily\bfseries,
title=Teorema~\thetcbcounter: #2,
#1
}
\newtcolorbox[auto counter, number within=chapter, number freestyle={\noexpand\thechapter.\noexpand\arabic{\tcbcounter}}]{lemma}[2][]{%
colback=white,
enhanced,
attach boxed title to top left = {xshift=0mm,yshift=-.1mm},
toprule=1pt, leftrule = 3pt, bottomrule = 1pt, rightrule =1pt,
arc = 0 mm, sharp corners, colframe=purple,
colframe=purple,colbacktitle=purple,
boxed title style = {frame code = { \fill[purple] (frame.south west)--(frame.north west)--(frame.north east)--([xshift=3mm]frame.east)--(frame.south east)--cycle;
\draw[line width=.5mm,purple]([xshift=2mm]frame.north east)--([xshift=5mm]frame.east)--([xshift=2mm]frame.south east);
}
},
breakable,
fonttitle=\sffamily\bfseries,
title=Lemma~\thetcbcounter: #2,
#1
}
\newtheorem*{remark}{Remark}
\theoremstyle{definition}
\newtheorem{defin}[\tcbcounter]{Definition}
\newtheorem{example}[\tcbcounter]{Example}
\newtheorem{exercise}[\tcbcounter]{Latihan}
\newtheorem{problem}[\tcbcounter]{Soal}
\theoremstyle{remark}
%-----------------------------NEW COMMAND
\newenvironment{solusi}[1][] {
\noindent \textit{Solusi.}
}{}
\newcommand{\theo}[1]{{\bfseries\color{MidnightBlue}\textsf{Teorema #1}}}
\newcommand{\ex}[1]{{\bfseries\color{ForestGreen}\textsf{Contoh #1}}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
%-----------------------------
\begin{document}
\parindent1cm
\chapter{Matriks}
\section{Jangan}
\begin{defin}[Matrix]
\end{defin}
\begin{theorem}{XYZ}
$2+3=5$
\end{theorem}
\begin{theorem}{PQR}
$2-1=1$
\end{theorem}
\begin{example}
$p+q=r$
\end{example}
\begin{theorem}{ABC}
100
\end{theorem}
\begin{lemma}{DEF}
def
\end{lemma}
\end{document}
答案1
我将使用theorems
tcolorbox 库:
\documentclass[a4paper,11pt]{book}
\usepackage{amsthm}
\usepackage[dvipsnames]{xcolor}
\usepackage[many]{tcolorbox}
\newtcbtheorem[number within=chapter]{theorem}{Teorema}{%
colback=white,
enhanced,
attach boxed title to top left = {xshift=0mm,yshift=-.1mm},
toprule=1pt, leftrule = 3pt, bottomrule = 1pt, rightrule =1pt,
arc = 0 mm, sharp corners, colframe=NavyBlue,
colframe=NavyBlue,colbacktitle=NavyBlue,
boxed title style = {frame code = { \fill[NavyBlue] (frame.south west)--(frame.north west)--(frame.north east)--([xshift=3mm]frame.east)--(frame.south east)--cycle;
\draw[line width=.5mm,NavyBlue]([xshift=2mm]frame.north east)--([xshift=5mm]frame.east)--([xshift=2mm]frame.south east);
}
},
breakable,
fonttitle=\sffamily\bfseries
}{theo}
\newtcbtheorem[use counter from=theorem]{lemma}{Lemma}{%
colback=white,
enhanced,
attach boxed title to top left = {xshift=0mm,yshift=-.1mm},
toprule=1pt, leftrule = 3pt, bottomrule = 1pt, rightrule =1pt,
arc = 0 mm, sharp corners, colframe=purple,
colframe=purple,colbacktitle=purple,
boxed title style = {frame code = { \fill[purple] (frame.south west)--(frame.north west)--(frame.north east)--([xshift=3mm]frame.east)--(frame.south east)--cycle;
\draw[line width=.5mm,purple]([xshift=2mm]frame.north east)--([xshift=5mm]frame.east)--([xshift=2mm]frame.south east);
}
},
breakable,
fonttitle=\sffamily\bfseries,
}{lem}
\newtheorem*{remark}{Remark}
\theoremstyle{definition}
\makeatletter
\newtheorem{defin}[tcb@cnt@theorem]{Definition}
\newtheorem{example}[tcb@cnt@theorem]{Example}
\newtheorem{exercise}[tcb@cnt@theorem]{Latihan}
\newtheorem{problem}[tcb@cnt@theorem]{Soal}
\makeatother
\begin{document}
\chapter{Matriks}
\section{Jangan}
\begin{defin}[Matrix]
some text
\end{defin}
\begin{theorem}{XYZ}{}
$2+3=5$
\end{theorem}
\begin{theorem}{PQR}{}
$2-1=1$
\end{theorem}
\begin{example}
$p+q=r$
\end{example}
\begin{theorem}{ABC}{}
100
\end{theorem}
\begin{lemma}{DEF}{}
def
\end{lemma}
\end{document}