语境
我想在lower
的一部分中显示一个图形旁边的一些文本tcolorbox
,并且我想将这个图形封装在另一个图形中tcolorbox
,但我还希望文本环绕它,因此我wrapfig
也使用。
问题
tikzpicture
(即图形)一直从 和 环境中伸出。tcolorbox
此外wrapfigure
,溢出的垂直对齐tikzpicture
会垂直拉伸tcolorbox
,这是不理想的。
平均能量损失
\documentclass[a4paper, 12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage[fixamsmath]{mathtools}
\DeclarePairedDelimiter {\pars} { ( } { ) }
\DeclarePairedDelimiter {\bracs} { [ } { ] }
\usepackage[dvipsnames, cmyk]{xcolor}
% Floats
\usepackage{float}
\usepackage{tcolorbox}
\usepackage{wrapfig}
\usepackage{calc}
%% Customising floats
\tcbuselibrary{%
skins,
theorems,
breakable
}
\tcbset{%
shield externalize
}
\usetikzlibrary{%
decorations.pathreplacing,
decorations.markings,
arrows.meta,
positioning,
intersections,
external
}
%%% Custom tcolorboxes
\NewTCBox
{\sectionbox}
{ O{Violet} !O{} } % 1: colour, 2: extra options
{
on line,
arc=7pt,
colback=#1!2.5!white,
colframe=#1!90!black,
colupper=#1,
boxrule=1pt,
boxsep=0pt,
left=6.5pt,
right=3pt,
top=3pt,
bottom=3pt,
before upper={\rule[-2.5pt]{0pt}{10pt}},
#2
}
%%%% Custom lengths
\newlength{\widthofexplanation}
\settowidth{\widthofexplanation}{\widthof{\sectionbox{\textbf{Explanation:}}}}
\addtolength{\widthofexplanation}{5mm}
\newlength{\setbackwidthofexplanation}
\setlength{\setbackwidthofexplanation}{\widthofexplanation}
\addtolength{\setbackwidthofexplanation}{1mm}
\NewTColorBox
{solutionbox}
{ O{Solution:} O{Violet} !O{} } % 1: before title declaration, 2: colour, 3: extra options
{
enhanced,
detach title,
coltitle=#2,
colframe=#2,
colback=white,
before upper*={\hspace{-\setbackwidthofexplanation}\makebox[\widthofexplanation][b]{\sectionbox{\textbf{#1}}}~\parindent15pt\noindent},
before lower*={\hspace{-\setbackwidthofexplanation}\makebox[\widthofexplanation][b]{\sectionbox{\textbf{Explanation:}}}~\parindent15pt\noindent},
left=\widthofexplanation,
#3
}
\NewTColorBox
[use counter=figure]
{figurebox}
{ s O{\textbf{Figure \thetcbcounter:}~} O{6cm} m !O{} } % {1: left or not, 2: before title declaration, 3: width, 4: title, 5: extra options}
{
enhanced,
title=#4,
fonttitle=\scriptsize,
colframe=red,
before title=#2,
arc=3.5mm,
sharp corners=downhill,
width=#3,
boxsep=0pt,
left=1pt,
right=1pt,
top=1pt,
bottom=1pt,
leftrule=\IfBooleanTF{#1}{3mm}{0.5mm}, % initial is 0.5mm
rightrule=\IfBooleanTF{#1}{0.5mm}{3mm}, % initial is 0.5mm
add to list={figures}{figure},
#5
}
\usepackage{adjustbox}
\usepackage{lipsum} % for dummy text
\begin{document}
\begin{solutionbox}
\( \bracs*{ \frac12, 1 } \)
%
\tcblower
%
\begin{wrapfigure}{r}{6.1cm}
\begin{figurebox}{A visual representation of the explanation using the unit circle}[center upper, valign=center, halign=center]
% \begin{adjustbox}{width=0.9\linewidth}
\begin{tikzpicture}[scale=1.25, baseline=(current bounding box.south)]
\clip[] (-5, -0.25) rectangle (5, 5);
\draw[very thin, -{Stealth[length=3pt]}] (0, -1.25) -- (0, 1.25) node[pos=1, font=\tiny, right] {$y$};
\draw[very thin, {Stealth[length=3pt]}-{Stealth[length=3pt]}] (-1.25, 0) -- (1.25, 0) node[pos=1, font=\tiny, right] {$x$};
\draw[very thin] (0,0) circle[radius=1];
\draw[densely dashed, dash pattern={on 1pt off 1pt}] (0,0) -- (30:1) node[gray, above, sloped, font=\tiny, inner sep=0, outer sep=1pt, pos=0.5] {\( \pi/6 \)} node[circle, fill=black, inner sep=0, minimum size=2pt] {} node[right, font=\tiny] {\( \pars*{ \frac{\sqrt3}2, \frac12 } \)};
\draw[densely dashed, dash pattern={on 1pt off 1pt}] (0,0) -- (150:1) node[gray, above, sloped, font=\tiny, inner sep=0, outer sep=1pt, pos=0.5] {\( 5\pi/6 \)} node[circle, fill=black, inner sep=0, minimum size=2pt] {} node[left, font=\tiny] {\( \pars*{ -\frac{\sqrt3}2, \frac12 } \)};
\draw[densely dashed, dash pattern={on 1pt off 1pt}] (0,0) -- (90:1) node[gray, right, font=\tiny, inner sep=0, outer sep=1pt, pos=0.75] {\( \pi/2 \)} node[circle, fill=black, inner sep=0, minimum size=2pt] {} node[above left, outer sep=2.5pt, inner sep=0, font=\tiny] {\( \pars*{ 0, 1 } \)};
\draw[gray, densely dashed, dash pattern={on 1pt off 1pt}, opacity=0.75, -{Stealth[length=3pt]}] (30:1.05) arc(30:150:1.05);
% \useasboundingbox (-5, -0.25) rectangle (5, 5);
\end{tikzpicture}
% \end{adjustbox}
\end{figurebox}
\end{wrapfigure}
%
\lipsum[1]
\end{solutionbox}
\end{document}
图像
答案1
从你的 tikzpicture 中删除\clip[] (-5, -0.25) rectangle (5, 5);
。
通过它您可以设置边界框从而使您的图像变大。