希望のレイアウトを与えるスタイルの実装

希望のレイアウトを与えるスタイルの実装

次の画像のようなボックスを正確に実現できるパッケージまたは方法があるかどうかを知りたいです。

前もって感謝します !

ここに画像の説明を入力してください

答え1

TeX.SE へようこそ!

希望のレイアウトを与えるスタイルの実装

コメントで述べたように、このボックス スタイルは強力な で取得できますtcolorbox。私はこれを 2 つの手順で実行します。

  1. my boxあらゆるものに適用できtcolorbox、必要なデザインを実装できるスタイルを定義します。

  2. スタイルを使用する と\newtcolorbox呼ばれる環境を定義するために使用します。myboxmy box

もちろん、必要に応じてmy box他の es にスタイルを適用することもできますtcolorbox。これが、2 つの操作を分離する主な目的です。

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{lipsum}

\definecolor{boxTitle}{HTML}{fff79a}
\definecolor{boxBackground}{HTML}{fffce0}
\definecolor{boxFrame}{HTML}{f1e2b8}

\tcbset{my box/.style={
    enhanced, fonttitle=\bfseries,
    colback=boxBackground, colframe=boxFrame,
    coltitle=black, colbacktitle=boxTitle,
    attach boxed title to top left={xshift=0.3cm,
                                    yshift*=-\tcboxedtitleheight/2},
    boxed title style={
      before upper=\hspace*{0.5cm}, % reserve space for the image
      overlay={
       \node at ([xshift=0.5cm]frame.west)
         {\includegraphics[scale=0.65]{bc-dodecaedre}};
      }
    }
  }
}

\newtcolorbox{mybox}[1][]{my box, #1}

\begin{document}

\begin{mybox}[title={This is a great title, with a comma}]
\lipsum[1]
\end{mybox}

\end{document}

スクリーンショット

注:bc-dodecaedreグラフィックスはパッケージから提供されるため、グラフィックス ( MetaPost で取得されたファイル)bclogoを表示するにはパッケージをインストールする必要があります。.mps

自動的に番号が付けられたボックス

コメントでのリクエストに応じて、前のセクションで開発したレイアウトを使用して、独立して番号が付けられた一連のボックスを作成する方法をいくつか示します (スタイルのおかげで、再利用が特に簡単ですmy box)。基本的に 2 つの方法があります。

  • auto counter最初のオプション引数で使用します\newtcolorbox(以下の例で定義されている 2 つのボックス シリーズ (タイプ A のボックスとタイプ B のボックス) を参照してください)。

  • theoremsのライブラリを使用しますtcolorbox(theorem例で定義されている環境を参照)。

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tcolorbox}
\tcbuselibrary{skins, theorems}
\usepackage{nameref}            % only needed if you use \nameref

\definecolor{boxTitle}{HTML}{fff79a}
\definecolor{boxBackground}{HTML}{fffce0}
\definecolor{boxFrame}{HTML}{f1e2b8}

\tcbset{my box/.style={
    enhanced, fonttitle=\bfseries,
    colback=boxBackground, colframe=boxFrame,
    coltitle=black, colbacktitle=boxTitle,
    attach boxed title to top left={xshift=0.3cm,
                                    yshift*=-\tcboxedtitleheight/2},
    boxed title style={
      before upper=\hspace*{0.5cm}, % reserve space for the image
      overlay={
       \node at ([xshift=0.5cm]frame.west)
         {\includegraphics[scale=0.65]{bc-dodecaedre}};
      }
    }
  }
}

\newtcolorbox[auto counter]{countedboxa}[2][]{%
  my box, title={Counted box of type A~(\thetcbcounter): #2}, #1}
\newtcolorbox[auto counter, number within=section]{countedboxb}[2][]{%
  my box, title={Counted box of type B.~(\thetcbcounter): #2}, #1}

\newtcbtheorem[number within=section]{theorem}{Theorem}{my box}{th}

\begin{document}

\section{First section}
\label{sec:first}

\begin{countedboxa}[label={first box of type A}]{Some title}
  My number is~\thetcbcounter.
\end{countedboxa}

\begin{countedboxb}[label={first box of type B}]{Other title}
  Note the different numbering style due to our use of
  \verb|number within=section| for boxes of type~B. My number is~\thetcbcounter.
\end{countedboxb}

\begin{countedboxa}[label={second box of type A}]{Another title}
  My number is~\thetcbcounter. The third box of type A is number~\ref{third
    box of type A} on page~\pageref{third box of type A}.
\end{countedboxa}

\begin{countedboxb}[label={second box of type B}]{The title}
   My number is~\thetcbcounter. The third box of type B is number~\ref{third
    box of type B} on page~\pageref{third box of type B}.
\end{countedboxb}

\begin{theorem}{Compacity of Foo spaces}{foo}
% Text (mostly) from the tcolorbox manual
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number due to our use of
\verb|number within=section|. This theorem is numbered \ref{th:foo}, found
on page~\pageref{th:foo} and titled ``\nameref{th:foo}.''
\end{theorem}

An immediate but very convenient consequence of this result is
theorem~\ref{th:bar}.

\begin{theorem}{Bar}{bar}
Trivial consequence of theorem~\ref{th:foo}.
\end{theorem}

\section{Second section}

\begin{countedboxa}[label={third box of type A}]{Some title}
  See boxes~\ref{first box of type A} and \ref{second box of type A} in
  section~\ref{sec:first}.
\end{countedboxa}

\begin{countedboxb}[label={third box of type B}]{Title of the box}
  See boxes~\ref{first box of type B} and \ref{second box of type B} in
  section~\ref{sec:first}.
\end{countedboxb}

\begin{theorem}{Quux}{quux}
This is a very important result.
\end{theorem}

\end{document}

ページ1:

ページ1


2ページ目の上部:

2ページ目の上部

答え2

ポイント 1 の答えは次のとおりですshaded box with round corner

\documentclass{book}
\usepackage[tikz]{mdframed}
\tikzset{titregris/.style =
{draw=black, thick, fill=yellow, %
text=black, rectangle, rounded corners, right,minimum height=.7cm}}

\makeatletter
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt,linecolor=black]
\node[titregris,anchor=east,rectangle,fill=yellow!20]
{\strut Theorem~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[titregris,anchor=east,rectangle,fill=yellow!20]
{\strut Theorem~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=yellow,roundcorner=5pt,backgroundcolor=yellow!10,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}
\makeatother
\begin{document}

\begin{theo}[Inhomogeneous Linear]
This is my own box with a mandatory title
and options.

This is my own box with a mandatory title
and options following para.
\end{theo}

\end{document}

そして、ポイント 2、つまりwavy vertical ruleテキストに関しては、まだ完了していませんが、何人かの専門家が答えてくれるかもしれません。その間、私も試しています...

関連情報