TikZ 中章节标题周围有花式轮廓的问题

TikZ 中章节标题周围有花式轮廓的问题
\documentclass[11pt]{book}

%\usepackage{estructuraLibro}

\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage{fourier}
\usepackage{microtype}
\usepackage[spanish, es-lcroman,es-tabla,es-noshorthands]{babel} % English language/hyphenation

\usepackage{multicol}
\usepackage{float}

\usepackage[
papersize={216mm,330mm}, 
lmargin=1.5cm, 
rmargin=1.5cm, 
top=1.5cm, 
bottom=1.5cm,
showframe=true,
noheadfoot, 
marginparsep=0cm
]{geometry}

\parindent=0mm

% Enhanced Equation support
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{mathrsfs}
\usepackage{bbm}

\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{calc}

\usepackage{tabularx}
\usepackage{xcolor}

\usepackage{tcolorbox}                             % Cajas de Teoremas, ejemplos, etc.
\tcbuselibrary{skins,breakable}                    % Librerías tcolorbox
\usepackage{tikz} % Required for drawing custom shapes
\usetikzlibrary{
    arrows,
    backgrounds,
    calc,
    calendar,
    chains,
    circuits,
    circuits.logic,
    decorations.pathmorphing,
    decorations.pathreplacing,
    decorations.fractals,
    decorations.footprints,
    decorations.markings,
    decorations.shapes,
    decorations.text,
    external,
    lindenmayersystems,
    matrix,
    mindmap,
    intersections,
    fadings,
    fit,
    folding,
    patterns,
    plotmarks,
    positioning,
    scopes,
    shadows,
    shapes,
    shapes.callouts,
    shapes.arrows,
    shapes.geometric,
    shapes.misc,
    shapes.multipart,
    shapes.symbols,
    shadings,
    through,
    topaths,
    trees
}



\newtcolorbox[auto counter]{mybox}[2][]{
    arc=0pt, % Radio interior de las cuatro esquinas de la caja
    breakable, % Soporte automatico para el corte de un tcolorbox
    enhanced jigsaw,
    colback=white, % Color de fondo de la caja
    colframe=red, % Color del marco de la caja
    left=5mm,
    top=3ex,
    bottom=0.5cm,
    right=0ex,
    bottom=0ex,
    outer arc=0pt,
    leftrule=0pt,
    rightrule=0pt,
    toprule=0pt,
    bottomrule=0pt,
    nobeforeafter,
    enlarge top by=\baselineskip/2+1mm,
    enlarge top at break by=0mm,pad at break=2mm,
    overlay={
        %Caja Tema
%       \node(a)[
%           starburst,
%           line width=2pt,
%           anchor=south west,
%           align=center,
%           inner sep = 2mm,
%           minimum width = 1in,
%           drop shadow,
%           fill=white,
%           rounded corners,
%           draw,
%           right] at ([shift={(5.2ex,0ex)}]frame.north west) {\textbf{Tema~\thetcbcounter: #2}};

        %\node (a) [right, smooth] at ([shift={(0.5ex,0ex)}]frame.north west) {\textbf{Tema~\thetcbcounter: #2}};
        \node[right,draw, line width = 2pt,minimum width = 1in,decorate,rectangle, decoration = {zigzag}, inner sep = 3mm, rounded corners] at ([shift={(0.5ex,0ex)}]frame.north west) {\textbf{Tema}};

%       % Caja descripción
%       \node[rectangle, 
%        text=black, 
%        inner sep=0mm,
%        anchor=west] at ([xshift=3cm,yshift=13.5pt]frame.north west)%
%        {\textbf{#2}};

        %barra vertical
        %\draw[color=black,line width=2pt,drop shadow] ([xshift=11pt,yshift=-12pt] frame.north west)--([xshift=11pt] frame.south west);
        \draw[color=black,line width=2pt] ([xshift=11pt,yshift=-13pt] frame.north west)--([xshift=11pt] frame.south west);
    },
    before=\vspace*{2em}\noindent,
    #1
  }

\newtcolorbox[auto counter]{tema}[1][]{colback=white, colframe=white,
    coltitle=black,
    title={\textsc{Tema~\thetcbcounter: #1}},
    enhanced,
    breakable,
    title code={%
        \draw[very thick,blue!50!cyan!80!black] 
        (title.south west) |- 
        ($(title.north west)!0.375!(title.north)$)--
        ($(title.south west)!0.375!(title.south)$)--++
        (-0.45em,0)--++
        (-115:2mm)--++
        (125:2mm)--cycle
        ;%
    },
    interior titled code={%
        \draw[very thick,blue!50!cyan!80!black]
        ([xshift=7pt]interior.north west) rectangle 
        ([xshift=7pt]interior.south west);%
    }
}

\begin{document}

    \begin{tema}[Eliminación de Gauss-Jordan]
        Hola
    \end{tema}
\end{document}

在此处输入图片描述

答案1

boxed title这是使用此类标注标题选项的另一种方法。

如果标题总是短于线宽,则可以使用以下代码(我还添加了一个太长的标题示例):

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}

\newtcolorbox[auto counter]{tema}[1][]{
  enhanced,breakable,
  frame hidden,interior hidden,boxrule=0pt,coltitle=black,
  title={\textsc{Tema~\thetcbcounter: #1}},
  attach boxed title to top left,
  boxed title style={enhanced,boxrule=0pt,left=4mm,right=4mm,top=1mm,bottom=1mm,
    frame hidden,
    interior code={\draw[very thick,blue!50!cyan!80!black]
      ([xshift=0.6pt,yshift=0.6pt]frame.south west)--([xshift=0.6pt,yshift=-0.6pt]frame.north west)
      --([xshift=-0.6pt,yshift=-0.6pt]frame.north east)--([xshift=-0.6pt,yshift=0.6pt]frame.south east)
      --++(-0.45em,0)--++(-115:2mm)--++(125:2mm)--cycle; }},
  underlay={%
      \draw[very thick,blue!50!cyan!80!black]
      ([xshift=7pt]interior.north west) --
      ([xshift=7pt]interior.south west); }
}

\begin{document}

   \begin{tema}[Eliminacion de Gauss-Jordan]
      Tema Hola
   \end{tema}

   \begin{tema}[A short title]
      Hola
   \end{tema}

   \begin{tema}[A very very very very very very long title]
      Hola
   \end{tema}

   \begin{tema}[A really really really really really really very very very very very very long title]
      Hola
   \end{tema}

\end{document}

在此处输入图片描述

如果还应该支持非常长的标题,我会添加varwidth选项内部使用的包varwidth boxed title

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage{varwidth}

\newtcolorbox[auto counter]{tema}[1][]{
  enhanced,breakable,
  frame hidden,interior hidden,boxrule=0pt,coltitle=black,
  title={\textsc{Tema~\thetcbcounter: #1}},
  attach boxed title to top left,
  varwidth boxed title*=0pt,
  boxed title style={enhanced,boxrule=0pt,left=4mm,right=4mm,top=1mm,bottom=1mm,
    frame hidden,
    interior code={\draw[very thick,blue!50!cyan!80!black]
      ([xshift=0.6pt,yshift=0.6pt]frame.south west)--([xshift=0.6pt,yshift=-0.6pt]frame.north west)
      --([xshift=-0.6pt,yshift=-0.6pt]frame.north east)--([xshift=-0.6pt,yshift=0.6pt]frame.south east)
      --++(-0.45em,0)--++(-115:2mm)--++(125:2mm)--cycle; }},
  underlay={%
      \draw[very thick,blue!50!cyan!80!black]
      ([xshift=7pt]interior.north west) --
      ([xshift=7pt]interior.south west); }
}

\begin{document}

   \begin{tema}[Eliminacion de Gauss-Jordan]
      Tema Hola
   \end{tema}

   \begin{tema}[A short title]
      Hola
   \end{tema}

   \begin{tema}[A very very very very very very long title]
      Hola
   \end{tema}

   \begin{tema}[A really really really really really really very very very very very very long title]
      Hola
   \end{tema}

\end{document}

在此处输入图片描述

答案2

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\usetikzlibrary{calc}

\newtcolorbox[auto counter]{tema}[1][]{colback=white, colframe=white,
coltitle=black,
title={\textsc{Tema~\thetcbcounter: #1}},
enhanced,
breakable,
title code={%
    \node(a)[anchor=north west]at($(title.north west)+(5mm,.5mm)$){\phantom{\textsc{Tema~\thetcbcounter: #1}}};    %NEW CODE HERE
    \draw[very thick,blue!50!cyan!80!black]
    ($(a.south west)+(-.5,0)$)--($(a.north west)+(-.5,0)$)--(a.north east)--(a.south east)--++(-0.45em,0)--++(-115:2mm)--++(125:2mm)--cycle
    ;%
},
interior titled code={%
    \draw[very thick,blue!50!cyan!80!black]
    ([xshift=7pt]interior.north west) rectangle
    ([xshift=7pt]interior.south west);%
}
}
\begin{document}
   \begin{tema}[Eliminacion de Gausss-Jordan]
      Hola
   \end{tema}

   \begin{tema}[A short title]
      Hola
   \end{tema}

   \begin{tema}[A very very very very very very long title]
      Hola
   \end{tema}

\end{document}

在此处输入图片描述 我在里面添加了一个幻影节点,title code用作绘制蓝色标注的骨架。新代码用注释标记。

相关内容