编号自定义定理样式的问题

编号自定义定理样式的问题

我会尝试在 beamer documnet 中使用我的自定义样式,如果我使用非编号定义或另一个我的自定义样式来定义定理和例子

\begin{myDefinition*}{Sample Definition}
This is a sample definition.
\end{myDefinition*}

\begin{myExample*}{Sample Definition}
This is a sample definition.
\end{myExample*}

\begin{myQuestion*}{Sample Definition}
This is a sample definition.
\end{myQuestion*}

\begin{myTheorem*}{Sample Definition}
This is a sample definition.
\end{myTheorem*}

一切正常,但如果我 del *,那么我想使用编号的自定义环境,我会出现这样的错误:

Missing \endcsname inserted.

我认为,此错误与使用不同的语言包有关(当我重新定义 myDefinition 样式时)

并且定义的第一个符号(标题后的描述字段)未显示...我不明白,如何解决这个问题?

我的序言代码:

\documentclass[aspectratio=169, 11pt]{beamer}

\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{lipsum}
\usefonttheme{professionalfonts}
\usepackage{concmath}
\usefonttheme{serif}
\usepackage{setspace}
\usepackage{indentfirst}
% \usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{hyperref}
\hypersetup{
    pdftitle={Assignment},
    colorlinks=true, linkcolor=black!90,
    bookmarksnumbered=true,
    bookmarksopen=true
}
\usepackage[most,many,breakable]{tcolorbox}
\usepackage{ragged2e}
\usepackage{etoolbox}
\usepackage{tikz-cd}
\usepackage{varwidth}

\setstretch{1.0}

\setlength{\parindent}{1.15cm}

\setlength{\parskip}{4pt}
\setlength{\emergencystretch}{3em}

\expandafter\def\expandafter\normalsize\expandafter{%
    \normalsize
    \setlength\abovedisplayskip{4pt}
    \setlength\belowdisplayskip{4pt}
    \setlength\abovedisplayshortskip{4pt}
    \setlength\belowdisplayshortskip{4pt}
}

\makeatletter
\long\def\beamer@@frametitle[#1]#2{%
  \ifblank{#2}{}{%
    \ifnum\beamer@autobreakcount<2
    \gdef\insertframetitle{{%
      #2%
    }}%
    \gdef\beamer@frametitle{#2}%
    \gdef\beamer@shortframetitle{#1}%
    \fi%
  }%
}

\setbeamertemplate{frametitle}[default][center]

\setbeamersize{text margin left=2em,text margin right=2em}

\setbeamertemplate{itemize items}[circle]

\setbeamerfont{title}{size=\LARGE}
\setbeamerfont{subtitle}{size=\Large}
\setbeamerfont{frametitle}{size=\Large}
\setbeamerfont{block title}{size=\normalsize}
\setbeamerfont{footline}{size=\normalsize}

\usebeamercolor{structure}
\setbeamercolor{normal text}{fg=black}
\setbeamercolor{structure}{bg=black!20,fg=black}

% \addtobeamertemplate{frametitle}{}{\vspace*{-1ex}\rule{\textwidth}{1pt}}

\setbeamertemplate{navigation symbols}{}

\setbeamertemplate{section in toc}[sections numbered]

\setbeamertemplate{subsection in toc}[subsections numbered]

\setbeamertemplate{subsection in toc}{\leavevmode\leftskip=3.2em\rlap{\hskip-2em\inserttocsectionnumber.\inserttocsubsectionnumber}\inserttocsubsection\par}

\makeatletter

\define@key{beamerframe}{s}[true]{% stretch
  \beamer@frametopskip=8pt\relax%
  \beamer@framebottomskip=4pt plus 0.0001fill\relax%
  \beamer@frametopskipautobreak=\beamer@frametopskip\relax%
  \beamer@framebottomskipautobreak=\beamer@framebottomskip\relax%
}

\def\beamer@initfirstlineunskip{%
    \def\beamer@firstlineitemizeunskip{%
      \vskip-\partopsep\vskip-\topsep\vskip-\parskip%
      \global\let\beamer@firstlineitemizeunskip=\relax}%
    \everypar{\global\let\beamer@firstlineitemizeunskip=\relax}}

\setbeamertemplate{footline}{%
   \centering
   \begin{minipage}{\dimexpr\paperwidth-\beamer@leftmargin-\beamer@rightmargin\relax}
    % \vspace{-4ex}
   \centering
   \rule{\linewidth}{1pt} \vskip -2pt
   \usebeamerfont{footline}%
   \usebeamercolor{footline}%
   % \hfill\insertpagenumber/\inserttotalframenumber
   \hfill\insertpagenumber
   \hfill%
   \llap{\insertframenavigationsymbol\insertbackfindforwardnavigationsymbol}\par
   \end{minipage}\vskip4pt
}

\makeatother

\definecolor{mytheoremfr}{HTML}{00007B}

\tcbuselibrary{theorems,skins,hooks}
\newtcbtheorem[number within=section]{myDefinition}{Определение}{enhanced,
    before skip=2mm, after skip=2mm, colback=black!7, colframe=black!65!white, boxrule=0.3mm,
    attach boxed title to top left={xshift=1cm, yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
    boxed title style={
        frame code={
            \path[fill=tcbcolback]
            ([yshift=-1mm,xshift=-1mm]frame.north west)
            arc[start angle=0, end angle=180, radius=1mm]
            ([yshift=-1mm,xshift=1mm]frame.north east)
            arc[start angle=180, end angle=0, radius=1mm];
            \path[left color=tcbcolback!45!white, right color=tcbcolback!45!white,
            middle color=tcbcolback!45!white]
            ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
            [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
            -- (frame.south east) -- (frame.south west)
            -- ([xshift=-1mm,yshift=-1mm]frame.north west)
            [sharp corners]-- cycle;
        },
        interior engine=empty,
    },
    fonttitle= \itshape \bfseries \color{black},
    title={#2},#1
}{def}

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=false,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

\title{\textbf{Linear Algebra}}
\apptocmd{\frame}{}{\justifying}{}

\begin{document}

\begin{frame}
\thispagestyle{empty}
  \titlepage
\end{frame}

\section{Intro}

\subsection{Intro I}

\begin{frame}[s, allowframebreaks] \frametitle{Intro I}
\begin{myDefinition}{Вектор}
Бла Бла Бла.
\end{myDefinition}
\end{frame}
\end{document}

这张图片展示了我的故障排除过程:

在此处输入图片描述

答案1

您的语法错误。您的自定义定理需要两个强制参数,一个用于标题,一个用于标签。您不能只省略一个。至少,它可以为空,但不能简单地缺失。

\documentclass[aspectratio=169, 11pt]{beamer}

\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}

\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage[most]{tcolorbox}
\usepackage{varwidth}
\definecolor{mytheoremfr}{HTML}{00007B}

\tcbuselibrary{theorems,skins,hooks}
\newtcbtheorem[number within=section]{myDefinition}{Определение}{enhanced,
    before skip=2mm, after skip=2mm, colback=black!7, colframe=black!65!white, boxrule=0.3mm,
    attach boxed title to top left={xshift=1cm, yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
    boxed title style={
        frame code={
            \path[fill=tcbcolback]
            ([yshift=-1mm,xshift=-1mm]frame.north west)
            arc[start angle=0, end angle=180, radius=1mm]
            ([yshift=-1mm,xshift=1mm]frame.north east)
            arc[start angle=180, end angle=0, radius=1mm];
            \path[left color=tcbcolback!45!white, right color=tcbcolback!45!white,
            middle color=tcbcolback!45!white]
            ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
            [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
            -- (frame.south east) -- (frame.south west)
            -- ([xshift=-1mm,yshift=-1mm]frame.north west)
            [sharp corners]-- cycle;
        },
        interior engine=empty,
    },
    fonttitle= \itshape \bfseries \color{black},
    title={#2},#1
}{def}



\begin{document}

\begin{frame} 

\begin{myDefinition}{Вектор}{quack}
Бла Бла Бла.
\end{myDefinition}

\ref{def:quack}

\begin{myDefinition}{Title}{}
Test
\end{myDefinition}

\end{frame}

\end{document}

在此处输入图片描述

相关内容