Implementieren eines Stils, der das gewünschte Layout liefert

Implementieren eines Stils, der das gewünschte Layout liefert

Ich würde gerne wissen, ob es ein Paket oder eine Methode gibt, um genau die Art von Box in der folgenden Abbildung zu erreichen.

Dank im Voraus !

Bildbeschreibung hier eingeben

Antwort1

Willkommen bei TeX.SE!

Implementieren eines Stils, der das gewünschte Layout liefert

Wie in den Kommentaren erwähnt, kann dieser Box-Stil mit dem leistungsstarken erreicht werden tcolorbox. Ich mache das in zwei Schritten:

  1. Definieren Sie einen my boxStil, der beliebig angewendet werden kann tcolorboxund das gewünschte Design umsetzt.

  2. \newtcolorboxWird zum Definieren einer Umgebung verwendet mybox, die den my boxStil verwendet.

Natürlich können Sie den my boxStil tcolorboxbei Bedarf auch auf andere es anwenden – das ist der Sinn der Trennung der beiden Vorgänge.

\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}

Bildschirmfoto

Hinweis: Die bc-dodecaedreGrafiken sind im bclogoPaket enthalten. Sie müssen dieses also installiert haben, um über die Grafiken zu verfügen ( .mpsDatei, erhalten mit MetaPost).

Automatisch nummerierte Boxen

Auf Ihre Anfrage in einem Kommentar folgend, sind hier mehrere Möglichkeiten, unabhängig nummerierte Reihen von Boxen mit dem Layout zu erstellen, das wir im vorherigen Abschnitt entwickelt haben (die Wiederverwendung ist dank des my boxStils besonders einfach). Es gibt grundsätzlich zwei Möglichkeiten:

  • Verwendung auto counterim ersten optionalen Argument von \newtcolorbox(siehe die beiden im folgenden Beispiel definierten Boxserien: Boxen vom Typ A und Boxen vom Typ B);

  • unter Verwendung der theoremsBibliothek von tcolorbox(siehe die theoremim Beispiel definierte Umgebung).

\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}

Seite 1:

Seite 1


Oben auf Seite 2:

Zum Seitenanfang 2

Antwort2

Hier ist die Antwort auf Ihren Punkt 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}

Und was Punkt 2 betrifft, also wavy vertical ruleden Text, der noch nicht fertig ist, können vielleicht einige Experten antworten. In der Zwischenzeit versuche ich es auch …

verwandte Informationen