定理環境をシンプルに作り直した

カラフルな定理環境を使っていたが、なんか白黒にしたいなとおもって作り直した。
可視性を高めるため、次のグループ分けを行った。
グループ1:定義、公理
グループ2:定理、命題、系、補題
グループ3:例、注意
各グループのボックスの形状は同じで、多少のデザインの違いをつけている。

定理環境

ソースコードをつけておくので、必要なら使ってほしい。
つくりなおしたときにコメントアウトだらけになったが、面倒なので全部は消してない。
追記:必要だとおもうパッケージを追記した。十分かはしらない。
追記(2024/01/08 16:32)使い方を先に述べる。

\begin{definition}{タイトル}{ラベル}
本文
\end{definition}

このようにして環境を使う。ラベルについては、各ボックスの定義の最後についているアルファベットがラベルの前につく。定義環境なら「de:」である。

     \newtcbtheorem[use counter from=theorem]{definition}{定義}{ 
         中略
     }{de}

先程のように定義を書いた場合、「de:ラベル」というラベルがつく。それを参照できるようになる。参照用のコマンドとして、\derefなどを用意した。
\deref{de:ラベル}とすれば、上の定義へのリンクが本文に出力される。
定理環境などその他も同様。

\usepackage[many]{tcolorbox}
\tcbuselibrary{breakable}
%*定理
    \newtcbtheorem[number within=subsection]{theorem}{定理}{
    boxtool,
    fonttitle=\gtfamily\sffamily\bfseries\upshape,
    enhanced,
    colback=white, %?背景色
    coltitle=black,
    boxrule=1pt,
    left=3mm,right=3mm,
    theorem style=standard,
    breakable,
    sharp corners,
    before skip=6pt,after skip=6pt, %ボックス上下の余白
    top=1mm,bottom=1mm, %ボックス内本文上下の余白
    before upper={\setlength{\parindent}{1\zw}},
    before lower={\setlength{\parindent}{1\zw}}, 
    separator sign={\ :},
    % description delimiters={《}{》},
    % description font=\mcfamily\mdseries,
    description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
    colbacktitle=white,
    borderline={2.5pt}{-1.5pt}{black},
    before skip=10pt,after skip=10pt, %ボックス上下の余白
    fuzzy shadow={2mm}{-2mm}{0mm}{0.3mm}{black},
    }{th}
%*命題
        \newtcbtheorem[use counter from=theorem]{prop}{命題}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        colback=white, %?背景色
        coltitle=black,
        boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        % borderline={1.5pt}{-0.5pt}{red!40!white},
        colbacktitle=black!20!white,
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        borderline={1.5pt}{-0.5pt}{black},
        }{pr}

%*系
%? 大きめのボックス
        \newtcbtheorem[use counter from=theorem]{cor}{系}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        % colframe=black, %?フレームの色
        % colback=thmcolor!2!backbasecolor,
        colback=white, %?背景色
        % colbacktitle=red!30!white,
        coltitle=black,
        boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        % borderline={1.5pt}{-0.5pt}{red!30!white},
        colbacktitle=white,
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        borderline={1pt}{-0.5pt}{black},
        }{co}

%*定義
%? 大きめのボックス
        \newtcbtheorem[use counter from=theorem]{definition}{定義}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        % colframe=black, %?フレームの色
        % colback=thmcolor!2!backbasecolor,
        colback=white, %?背景色
        % colbacktitle=red!30!white,
        coltitle=black,
        boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        attach boxed title to top left, %?タイトルをボックスで左上につける
        boxed title style={colframe=black,boxrule=1.5pt,colback=white,sharp corners}, %?タイトルのボックスのスタイル
        attach boxed title to top left={xshift=3mm, yshift*=-\tcboxedtitleheight/2},
        colframe=black,
        %     colback=defcolor!2!backbasecolor,
        colbacktitle=black!30!white,
        borderline={1.5pt}{-0.5pt}{black},
        }{de}
%*公理
%? 大きめのボックス
        \newtcbtheorem[use counter from=theorem]{axiom}{公理}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        % colframe=black, %?フレームの色
        % colback=thmcolor!2!backbasecolor,
        colback=white, %?背景色
        % colbacktitle=red!30!white,
        coltitle=black,
        boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        attach boxed title to top left, %?タイトルをボックスで左上につける
        boxed title style={colframe=black,boxrule=1.5pt,colback=white,sharp corners}, %?タイトルのボックスのスタイル
        attach boxed title to top left={xshift=3mm, yshift*=-\tcboxedtitleheight/2},
        colframe=black,
        %     colback=defcolor!2!backbasecolor,
        colbacktitle=black!30!white,
        borderline={1.5pt}{-0.5pt}{black},
        }{ax}

%*記号
        \newtcbtheorem[use counter from=theorem]{symbolset}{記号}{
        tatebou,blanker,breakable,
        left=3mm,right=3mm,
        top=3mm,bottom=3mm,
        % before skip=15pt,after skip=15pt,
        borderline={0.5pt}{0pt}{black}
        % after upper=\hfill\square %ボックス末尾につける記号
        }{sy}
        % \newcommand{\syref}[1]{{\bfseries\sffamily 記号 \ref{#1}}}

%*補題
%? 大きめのボックス
        \newtcbtheorem[use counter from=theorem]{lemma}{補題}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        % colframe=black, %?フレームの色
        % colback=thmcolor!2!backbasecolor,
        colback=white, %?背景色
        % colbacktitle=red!30!white,
        coltitle=black,
        % boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        frame hidden,
        boxrule=0pt,
        % borderline={1.5pt}{-0.5pt}{red!30!white},
        colbacktitle=white,
        titlerule style={black,dotted},
        titlerule=1pt,
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        borderline={1pt}{-0.5pt}{dashed,black},
        }{le}

%*例
%? 大きめのボックス
        \newtcbtheorem[use counter from=theorem]{example}{例}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        % colframe=black, %?フレームの色
        % colback=thmcolor!2!backbasecolor,
        colback=white, %?背景色
        % colbacktitle=red!30!white,
        coltitle=black,
        % boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        % colframe=excolor!50!white,
        frame hidden,
        %     colback=excolor!2!backbasecolor,
        colbacktitle=white,
        % borderline={1.5pt}{-0.5pt}{excolor!50!white},
        borderline horizontal={1pt}{0pt}{black},
        titlerule style={dotted},
        titlerule=1pt,
        }{ex}

%*注意
%? 大きめのボックス
        \newtcbtheorem[use counter from=theorem]{remark}{注意}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        % colframe=black, %?フレームの色
        % colback=thmcolor!2!backbasecolor,
        colback=white, %?背景色
        colbacktitle=black!15!white,
        coltitle=black,
        % boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        % colframe=excolor!50!white,
        % frame hidden,
        boxrule=0mm,toprule=1pt,bottomrule=1pt,
        colback=black!6!white,
        % colbacktitle=white,
        % borderline={1.5pt}{-0.5pt}{excolor!50!white},
        % borderline horizontal={1pt}{0pt}{black},
        % titlerule=1pt,
        % titlerule style={dotted},
        }{re}

%*補足
        % \newtcbtheorem[use counter from=theorem]{hosoku+}{補足}%
        % {mytheo,
        % colframe=hosokucolor!20!white,
        % %     colback=recolor!2!backbasecolor,
        % % colbacktitle=recolor,
        % borderline={0.5pt}{-0.5pt}{hosokucolor},
        % }{sup}

        \newtcbtheorem[use counter from=theorem]{hosoku+}{補足}{
        boxtool,
        fonttitle=\gtfamily\sffamily\bfseries\upshape,
        enhanced,
        % colframe=black, %?フレームの色
        % colback=thmcolor!2!backbasecolor,
        colback=white, %?背景色
        colbacktitle=black!15!white,
        coltitle=black,
        % boxrule=1pt,
        % borderline south={2pt}{-2pt}{red!50!white},
        % borderline={1.5pt}{-0.5pt}{red!50!white},
        % borderline east={1.5pt}{-0.5pt}{red!50!white},
        % borderline west={1.5pt}{-0.5pt}{red!50!white},
        % left*=1\zw,right*=1\zw,
        left=3mm,right=3mm,
        theorem style=standard,
        breakable,
        sharp corners,
        before skip=6pt,after skip=6pt, %ボックス上下の余白
        top=1mm,bottom=1mm, %ボックス内本文上下の余白
        before upper={\setlength{\parindent}{1\zw}},
        before lower={\setlength{\parindent}{1\zw}}, 
        separator sign={\ :},
        % description delimiters={《}{》},
        % description font=\mcfamily\mdseries,
        description font=\gtfamily\sffamily\bfseries\upshape,%!ここまでmythmのコピー
        % colframe=excolor!50!white,
        % frame hidden,
        boxrule=0mm,toprule=1pt,bottomrule=1pt,
        colback=black!6!white,
        % colbacktitle=white,
        % borderline={1.5pt}{-0.5pt}{excolor!50!white},
        % borderline horizontal={1pt}{0pt}{black},
        % titlerule=1pt,
        % titlerule style={dotted},
        }{sup}

\newcommand{\axref}[1]{{公理}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\deref}[1]{{定義}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\syref}[1]{{記号}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\thref}[1]{{定理}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\prref}[1]{{命題}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\coref}[1]{{系}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\prfref}[1]{{証明}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\leref}[1]{{補題}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\exref}[1]{{例}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\reref}[1]{{注意}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\supref}[1]{{補足}\ref{#1}\ (p.\pageref{#1})}
\newcommand{\prbref}[1]{{演習}\ref{#1}\ (p.\pageref{#1})}



この記事が気に入ったらサポートをしてみませんか?