在自定义环境中更改字体大小和样式

在自定义环境中更改字体大小和样式

我正在使用来自教科书。该模板有几个自定义环境(例如定理、练习等),它们在一个框中概述并具有标题样式。

    \newenvironment{boxtheorem}
    {\begin{tcolorbox}
    [enhanced jigsaw,breakable,pad at break*=1mm,
    colback=black!5,colframe=tsorange]}
    {\end{tcolorbox}}

    \newtheoremstyle{styletheorem}
    {0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{tsorange}}{\;}{0.25em}
    {\small\sffamily\color{tsorange}\thmname{#1}
    \nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}
    \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} (#3) \newline}}

    \theoremstyle{styletheorem}
    \newtheorem{envtheorem}{Derivation}[chapter]

    \newenvironment{theorem}
               {\begin{boxtheorem}\begin{envtheorem}}
               {\end{envtheorem}\end{boxtheorem}}

这个环境看起来是这样的:

在此处输入图片描述

我想从本质上复制这个环境,它将作为一个“历史人物”部分,其中将显示一个人的小照片和简历。我发现wrapfigure在环境中效果不佳,但我认为我找到了一种解决方法,使用小页面

现在我有以下用于自定义环境的代码:

\newenvironment{boxhistory}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
colback=tsgrey1!50,boxrule=0pt,frame hidden]}
{\end{tcolorbox}}

\newtheoremstyle{stylehistory}
{0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{black}}{\;}{0.25em}
{\small\sffamily\color{black}\thmname{#1}
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} #3 \newline}}

\theoremstyle{stylehistory}
\newtheorem{envhistory}{Historical Figure:}[chapter]

\newenvironment{history}
                {\begin{boxhistory}\begin{envhistory}}          
                {\end{envhistory}\end{boxhistory}}

在 minipage 中包装环境可使图形包装正常工作:

\begin{history}[Pavel Cherenkov]
    \begin{minipage}{\linewidth} 
    \begin{wrapfigure}{l}{0.28\textwidth}
        \centering
        \includegraphics[width=1\linewidth]{Figures/Radiation Generation/pavel_cherenkov.jpg}
    \end{wrapfigure}
    \footnotesize Cherenkov was born in 1904 to Alexey Cherenkov and Mariya Cherenkova in the small village of Novaya Chigla. This town is in present-day Voronezh Oblast, Russia.
    
    In 1928, he graduated from the Department of Physics and Mathematics of Voronezh State University. In 1930, he took a post as a senior researcher in the Lebedev Physical Institute. That same year he married Maria Putintseva, daughter of A.M. Putintsev, a Professor of Russian Literature. They had a son, Alexey, and a daughter, Yelena.
    
    Cherenkov was promoted to section leader, and in 1940 was awarded the degree of Doctor of Physico-Mathematical Sciences. In 1953, he was confirmed as Professor of Experimental Physics. Starting in 1959, he headed the institute's photo-meson processes laboratory. He remained a professor for fourteen years. In 1970, he became an Academician of the USSR Academy of Sciences.
    
    Cherenkov died in Moscow on January 6, 1990, and was buried in Novodevichy Cemetery.
    \end{minipage} 
\end{history}

它看起来像这样: 在此处输入图片描述

我的问题如下:

  1. 我怎样才能让框内的文本变小,类似于\footnotesize在环境中定义的文本?
  2. 如何获得自然缩进?我希望每个段落都缩进。
  3. 如何增加标题和第一行之间的间距?

如果可能的话,我希望这些变化可以在环境中定义。额外的好处是可以找到一种更好的方法让文字环绕图形在环境中工作。感谢您的任何建议!

完整代码如下:

%% tstextbook.cls
%% Copyright 2016 Typesetters.se
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This is a free LaTeX text book template from Typesetters.se.
% See tstextbook.tex for an example of how to use this class.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tstextbook}[2017/02/19 Free LaTeX text book template from Typesetters.se]
\LoadClass[11pt,onecolumn,titlepage,twoside=semi,openany]{book}

% Language
%--------------------------------------------------------------------------
%\RequirePackage[swedish]{babel}
\RequirePackage[utf8]{inputenc}

% Geometry
%--------------------------------------------------------------------------
\RequirePackage[top=2.5cm,bottom=2.5cm,left=3cm,right=3cm,
                marginparwidth=1.1cm,marginparsep=2mm]{geometry}
%\geometry{asymmetric}

% Fonts
%--------------------------------------------------------------------------
\RequirePackage{kpfonts}

% Colors
%--------------------------------------------------------------------------
\RequirePackage{xcolor}
\definecolor{tssteelblue}{RGB}{70,130,180}
\definecolor{tsorange}{RGB}{255,138,88}
\definecolor{tsblue}{RGB}{23,74,117}
\definecolor{tsforestgreen}{RGB}{21,122,81}
\definecolor{tsyellow}{RGB}{255,185,88}
\definecolor{tsgrey}{RGB}{226,236,217}
\definecolor{tsgrey1}{RGB}{208,206,206}

% Graphics
%--------------------------------------------------------------------------
\RequirePackage{graphicx}
\graphicspath{{images/}}
\RequirePackage{tikz}
\RequirePackage[pages=some]{background}
\backgroundsetup{scale=1,color=black,opacity=1.0,angle=0,
contents={\includegraphics[width=\paperwidth,height=\paperheight]{cover_cloud_chamber}}}
\usepackage[font=small,labelfont=bf]{caption}

% Header and footer styling
%--------------------------------------------------------------------------
\RequirePackage{fancyhdr}
\setlength{\headheight}{15.0pt}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[RE]{\it\sf\nouppercase{\rightmark}}
\fancyhead[LO]{\it\sf\nouppercase{\leftmark}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

% Section styling
%--------------------------------------------------------------------------
\RequirePackage{sectsty}
\sectionfont{\sf\color{tssteelblue}\sectionrule{0ex}{0pt}{-1ex}{1pt}}
\reversemarginpar
\@mparswitchfalse%

% Chapter styling
%--------------------------------------------------------------------------
\makeatletter

% Numbered chapters (with minitoc)
\renewcommand{\@makechapterhead}[1]{
    \begin{tikzpicture}[remember picture,overlay]
        \node at (current page.north west)
        {
            \begin{tikzpicture}[remember picture,overlay]
                % Background image
                \node[anchor=north west,inner sep=0pt] at (0,0)
                {\includegraphics[width=\paperwidth]{chapter_heading_cloud_chamber}};
                % Chapter heading
                \draw[anchor=west, inner sep=0pt] (-0.1cm,-1.5cm) node
                [black,
                ultra thick,
                fill=tsorange!10,
                fill opacity=.6,
                inner sep=10pt]
                (0,0)
                {\parbox[t][1.6cm][t]{\paperwidth}
                    {\huge\bfseries\sffamily\flushleft\thechapter. #1}};
                % Chapter contents
                \draw[anchor=west,inner sep=0pt] (8.8cm,-7cm) node
                [tssteelblue,
                ultra thick,
                fill=white,
                fill opacity=.8,
                draw=tssteelblue,
                draw opacity=1,
                line width=1.5pt,
                rounded corners,
                inner sep=0pt]
                (0,0)
                {\hspace{1cm}\parbox[t][][t]{11cm}
                    {\vspace{-0.5cm}\huge\bfseries\sffamily\flushleft
                        \textcolor{black}{\sffamily\minitoc}}};
            \end{tikzpicture}
        };
    \end{tikzpicture}
    \vspace{7.5cm}
}

% Unnumbered chapters (without minitoc)
\renewcommand{\@makeschapterhead}[1]{
  \begin{tikzpicture}[remember picture,overlay]
    \node at (current page.north west)
  {
    \begin{tikzpicture}[remember picture,overlay]
      % Background image
      \node[anchor=north west,inner sep=0pt] at (0,0)
           {\includegraphics[width=\paperwidth]{chapter_heading_cloud_chamber}};
      % Chapter heading
      \draw[anchor=west,inner sep=0pt] (-0.1cm,-1.5cm) node
           [black,
            ultra thick,
            fill=tsorange!10,
            fill opacity=.6,
            inner sep=10pt]
           (0,0)
           {\parbox[t][1.6cm][t]{\paperwidth}
           {\huge\bfseries\sffamily\flushleft #1}};
    \end{tikzpicture}
  };
\end{tikzpicture}
\vspace{8cm}
}

% Minitoc styling
%--------------------------------------------------------------------------
\RequirePackage{minitoc}
\setcounter{minitocdepth}{1}
\dominitoc[n]
\nomtcrule
\nomtcpagenumbers
\renewcommand{\mtifont}{\large\sffamily}
\renewcommand{\mtcfont}{\small\sffamily}
\renewcommand{\mtcSfont}{\small\sffamily}
\renewcommand{\mtcSSfont}{\small\sffamily}
\renewcommand{\mtcSSSfont}{\small\sffamily}

% Table of contents styling
%--------------------------------------------------------------------------
\RequirePackage{titletoc}
\setcounter{tocdepth}{1}

\titlecontents{chapter}[0cm]
{\addvspace{14pt}\large\sffamily\bfseries}
{\color{tssteelblue}\contentslabel[\Large\thecontentslabel]{1.25cm}}{}
{\color{tssteelblue}\normalsize\sffamily\bfseries
 \;\titlerule*[.5pc]{.}\;\thecontentspage}

\titlecontents{section}[0cm]
{\addvspace{6pt}\sffamily\bfseries}
{\contentslabel[\thecontentslabel]{1.25cm}}{}
{\sffamily\hfill\color{black}\thecontentspage}[]

% Front matter
%--------------------------------------------------------------------------
\newcommand{\tsbook}[9]{

\pagestyle{empty}

\def\@tstitle{#1}
\def\@tsauthor{#2}
\def\@tscoverdesign{#3}
\def\@tsyear{#4}
\def\@tsartno{#5}
\def\@tsisbn{#6}
\def\@tsedition{#7}
\def\@tspublished{#8}
\def\@tsprinted{#9}

% Title page
\BgThispage
\begin{center}
  \null
  \smallskip

  \color{white}
  \sffamily

  %\Huge
  %\textsc{\@tstitle}

  %\bigskip
  %\smallskip

  %\LARGE
  %\textsc{\@tsauthor} %\\[1em]
\end{center}
  %\Large
  %\textsc{\@tspublished}
%\end{center}

\pagebreak

% Copyright page
\null
\vfill
\begin{flushleft}
  Copyright \copyright \ \@tsyear \ \@tsauthor \\
  \vspace{5mm}
  \textbf{Copying prohibited} \\
  \vspace{5mm}
  All rights reserved. No part of this publication may be reproduced
  or transmitted in any form or by any means, electronic or
  mechanical, including photocopying and recording, or by any
  information storage or retrieval system, without the prior written
  permission of the author.\\
  %\vspace{5mm}
  %Art. No \@tsartno \\
  %ISBN \@tsisbn \\
  %Edition \@tsedition \\
  \vspace{5mm}
  Cover image by \@tscoverdesign \\
  %Published by \@tspublished \\
  %Printed in \@tsprinted
\end{flushleft}

% Table of contents
\tableofcontents

\cleardoublepage
\pagestyle{fancy}
\thispagestyle{empty}
}

% Boxes for theorems
%--------------------------------------------------------------------------
\newenvironment{boxtheorem}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
 colback=black!5,colframe=tsorange]}
{\end{tcolorbox}}

\newenvironment{boxdefinition}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
 colback=yellow!10!white,boxrule=0pt,frame hidden,
 borderline west={1.5mm}{-2mm}{tsforestgreen}]}
{\end{tcolorbox}}

\newenvironment{boxanswer}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
 colback=tsyellow!20,boxrule=0pt,frame hidden]}
{\end{tcolorbox}}

\newenvironment{boxquestion}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
 colback=tsorange!25,boxrule=0pt,frame hidden]}
{\end{tcolorbox}}

\newenvironment{boxhomework}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
 colback=tsblue!10,boxrule=0pt,frame hidden]}
{\end{tcolorbox}}

\newenvironment{boxexample}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
 colback=tsforestgreen!10,boxrule=0pt,frame hidden]}
{\end{tcolorbox}}

\newenvironment{boxsolution}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
colback=tsforestgreen!10,boxrule=0pt,frame hidden]}
{\end{tcolorbox}}

\newenvironment{boxhistory}
{\begin{tcolorbox}
[enhanced jigsaw,breakable,pad at break*=1mm,
colback=tsgrey1!50,boxrule=0pt,frame hidden]}
{\end{tcolorbox}}

% Styling of theorems
%--------------------------------------------------------------------------
\RequirePackage{amsthm}
\usepackage{enumitem}

\newtheoremstyle{styletheorem}
{0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{tsorange}}{\;}{0.25em}
{\small\sffamily\color{tsorange}\thmname{#1}
 \nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}
 \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} (#3) \newline}}

\newtheoremstyle{styledefinition}
{0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{black}}{\;}{0.25em}
{\small\sffamily\color{tsforestgreen}\thmname{#1}
 \nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}
 \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} (#3) \newline}}

\newtheoremstyle{styleexercise}
{0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{black}}{\;}{0.25em}
{\small\sffamily\color{black}\thmname{#1}
 \nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}
 \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} (#3) \newline}}

\newtheoremstyle{styleexercise1}
{0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{black}}{\;}{0.25em}
{\small\sffamily\color{black}\thmname{#1}
%\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} (#3) \newline}}

\newtheoremstyle{styleexercise2}
{0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{black}}{\;}{0.25em}
{\small\sffamily\color{black}\thmname{#1}
%\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} (#3)}}

\newtheoremstyle{stylehistory}
{0pt}{0pt}{\normalfont}{0pt}{\small\bf\sffamily\color{black}}{\;}{0.25em}
{\small\sffamily\color{black}\thmname{#1}
%\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black} #3 \newline}}

\theoremstyle{styledefinition}
\newtheorem{envdefinition}{Definition}[chapter]
\theoremstyle{styletheorem}
\newtheorem{envtheorem}{Derivation}[chapter]
\newtheorem{envlemma}{Lemma}[chapter]
\theoremstyle{styleexercise1}
\newtheorem{envanswer}{Answer:}[chapter]
\newtheorem{envquestion}{Question:}[chapter]
\theoremstyle{styleexercise}
\newtheorem{envhomework}{Homework Exercise}[chapter]
\newtheorem{envexample}{Example}[chapter]
\theoremstyle{stylehistory}
\newtheorem{envhistory}{Historical Figure:}[chapter]

% Environments for theorems
%--------------------------------------------------------------------------
\newenvironment{definition}
               {\begin{boxdefinition}\begin{envdefinition}}
               {\end{envdefinition}\end{boxdefinition}}

\newenvironment{theorem}
               {\begin{boxtheorem}\begin{envtheorem}}
               {\end{envtheorem}\end{boxtheorem}}

\newenvironment{corollary}
               {\begin{boxtheorem}\begin{envtheorem}}
               {\end{envtheorem}\end{boxtheorem}}

\newenvironment{lemma}
               {\begin{boxtheorem}\begin{envlemma}}
               {\end{envlemma}\end{boxtheorem}}

\newenvironment{answer}
               {\begin{boxanswer}\begin{envanswer}}
               {\end{envanswer}\end{boxanswer}}

\newenvironment{question}
               {\begin{boxquestion}\begin{envquestion}}
               {\end{envquestion}\end{boxquestion}}

\newenvironment{homework}
               {\begin{boxhomework}\begin{envhomework}}
               {\end{envhomework}\end{boxhomework}}

\newenvironment{example}
               {\begin{boxexample}\begin{envexample}}
               {\end{envexample}\end{boxexample}}
           
\newenvironment{solution}
               {\begin{boxsolution}\begin{envsolution}}
               {\end{envsolution}\end{boxsolution}}
           
\newenvironment{history}
                {\begin{boxhistory}\begin{envhistory}}          
                {\end{envhistory}\end{boxhistory}}


% Other environments
%--------------------------------------------------------------------------
\newenvironment{summary}
{\hspace{10pt}\par\small\it
 \begin{list}{}{\leftmargin=35pt\rightmargin=25pt}
 \item\ignorespaces\advance\baselineskip -1pt}
{\end{list}\vspace{-0.5cm}}

\newenvironment{remark}
{\vspace{0.5cm}\noindent\small\it
 \marginpar{\vspace{-6mm}\includegraphics[width=1.0cm]{idea}}}
{\vspace{0.5cm}}

% Bibliography
%--------------------------------------------------------------------------
\RequirePackage[backend=biber]{biblatex}
\addbibresource{bibliography.bib}

% Index
%--------------------------------------------------------------------------
\RequirePackage{makeidx}
\makeindex

% Packages for mathematics and algorithms
%--------------------------------------------------------------------------
\RequirePackage{algorithm}
\RequirePackage{algpseudocode}
\RequirePackage{xfrac}
\RequirePackage{mathtools}
\RequirePackage{wasysym}
\RequirePackage{siunitx}
\newcommand\bmmax{2}
\RequirePackage{bm}
\usepackage{cases}
\usepackage{wrapfig}
\usepackage{cutwin}

% Other useful packages
%--------------------------------------------------------------------------
\RequirePackage{blindtext}
\RequirePackage[most]{tcolorbox}
\RequirePackage{booktabs}
\RequirePackage{url}

\documentclass{tstextbook}
\begin{document}

\section{Cherenkov Radiation}
A charged particle moving with uniform velocity can NOT generate radiation in a vacuum.  However, when a charged particle moves in a dielectric medium with refractive index $\textit{n}$, it becomes possible to irradiate!  This was indeed discovered experimentally by the Russian physicist, Pavel Cherenkov in 1934, and later explained theoretically by Ilya Tamm and Igor Frank in 1937. They received the Nobel Prize for this discovery in 1958.
\begin{history}[Pavel Cherenkov]
    \begin{minipage}{\linewidth} 
    \begin{wrapfigure}{l}{0.28\textwidth}
        \centering
        \includegraphics[width=1\linewidth]{Figures/Radiation Generation/pavel_cherenkov.jpg}
    \end{wrapfigure}
    Cherenkov was born in 1904 to Alexey Cherenkov and Mariya Cherenkova in the small village of Novaya Chigla. This town is in present-day Voronezh Oblast, Russia.
    
    In 1928, he graduated from the Department of Physics and Mathematics of Voronezh State University. In 1930, he took a post as a senior researcher in the Lebedev Physical Institute. That same year he married Maria Putintseva, daughter of A.M. Putintsev, a Professor of Russian Literature. They had a son, Alexey, and a daughter, Yelena.
    
    Cherenkov was promoted to section leader, and in 1940 was awarded the degree of Doctor of Physico-Mathematical Sciences. In 1953, he was confirmed as Professor of Experimental Physics. Starting in 1959, he headed the institute's photo-meson processes laboratory. He remained a professor for fourteen years. In 1970, he became an Academician of the USSR Academy of Sciences.
    
    Cherenkov died in Moscow on January 6, 1990, and was buried in Novodevichy Cemetery.
    \end{minipage} 
\end{history}
\end{document}

相关内容