在 Beamer 中的定理环境中对齐文本

在 Beamer 中的定理环境中对齐文本

我试图不仅在块和框架中而且在定理块中获取对齐文本。我尝试了两个代码:

\addtobeamertemplate{block begin}{}{\justifying}

\apptocmd{\block}{}{\justifying}{}

两者都不起作用。

请问有什么想法吗?

这是我的 mwe

\documentclass[envcountsect,usenames,x11names,svgnames,spanish]{beamer}

\usetheme{Madrid}
\useoutertheme{infolines}

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


\usepackage{textcomp}
\usepackage{ae,aecompl,aeguill}
\usepackage{amsthm}
\usepackage{stmaryrd}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{ragged2e} % For justifying text


\definecolor{bluepigment}{rgb}{0.25, 0.25, 0.5}
\makeatletter
\def\th@definition{%
\itshape % body font
\setbeamercolor{block title example}{bg=bluepigment,fg=white}
\setbeamercolor{block body example}{bg=bluepigment!25,fg=black}
\setbeamercolor{example text}{fg=bluepigment}
\def\inserttheoremblockenv{exampleblock}
  }
\makeatother
\theoremstyle{definition}
\newtheorem{definicion}{Definición}[section]% Definition


\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.


\begin{document}

\begin{frame}

\lipsum[2]

\begin{definicion}[Lipsum text]

\lipsum[2]

\end{definicion}

\end{frame}

PD:我需要etoolbox包裹来装这句话

\apptocmd{\frame}{}{\justifying}{}

但在其他投影机上,我使用了不带包的此命令。它是由其他包加载的吗???

谢谢

答案1

你可以这样做\addtobeamertemplate{theorem begin}{}{\justifying}

\documentclass{beamer}

\usetheme{Madrid}
\useoutertheme{infolines}

\usepackage{lipsum}
\usepackage{ragged2e} % For justifying text

\definecolor{bluepigment}{rgb}{0.25, 0.25, 0.5}
\makeatletter
\def\th@definition{%
    \itshape % body font
    \setbeamercolor{block title example}{bg=bluepigment,fg=white}
    \setbeamercolor{block body example}{bg=bluepigment!25,fg=black}
    \setbeamercolor{example text}{fg=bluepigment}
    \def\inserttheoremblockenv{exampleblock}
}
\makeatother

\theoremstyle{definition}
\newtheorem{definicion}{Definición}[section]% Definition

\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.

\addtobeamertemplate{theorem begin}{}{\justifying}

\begin{document}

\begin{frame}
    \lipsum[2]

    \begin{definicion}[Lipsum text]
    \lipsum[2]
    \end{definicion}
\end{frame}

\end{document}

在此处输入图片描述

相关内容