当我使用 命令 时,出现了一个矩形和一个正方形\draw[clip]
,但我只需要内部的正方形。我应该怎么做才能删除外部的矩形?当我使用 时\path
,矩形和正方形都消失了。
\documentclass[a4paper, 11pt]{article}
\usepackage[a4paper,
tmargin=2cm,%
rmargin=2cm,%
bmargin=2cm,%
lmargin=2cm,
vscale=1,%
hscale=1]{geometry}
\usepackage{tikz}
% only used for the example
\newlength{\skiplength}
\setlength{\skiplength}{1cm}
\setlength{\parskip}{\skiplength}
\setlength{\parindent}{0pt}
\begin{document}
\centering{
A1\\
\vspace{\skiplength}
\begin{tikzpicture}[x=11.1cm, y=7.5cm]
\draw [clip=true model=individual] (0, 0) -- (1, 0) -- (1, 1) -- (0, 1) -- cycle
(2cm, 0.5cm)
[rounded corners=5pt] -- (2cm, 2.5cm)
[rounded corners=10pt] -- (4cm, 2.5cm)
[rounded corners=0.5cm] -- (4cm, 0.5cm)
[sharp corners] -- cycle;
\node[anchor=south west,%
inner sep=0,%
outer sep=0pt] (image) at (0, 0) {\includegraphics{a1_03}};
\end{tikzpicture}
}
\end{document}
答案1
这就是你想做的事吗?
\documentclass[a4paper, 11pt]{article}
\usepackage[a4paper,
tmargin=2cm,%
rmargin=2cm,%
bmargin=2cm,%
lmargin=2cm,
vscale=1,%
hscale=1]{geometry}
\usepackage{tikz}
% only used for the example
\newlength{\skiplength}
\setlength{\skiplength}{1cm}
\setlength{\parskip}{\skiplength}
\setlength{\parindent}{0pt}
\usetikzlibrary{graphs,graphs.standard}
\tikzset{
clip even odd rule/.code={\pgfseteorule}, % Credit to Andrew Stacey
invclip/.style = {
clip,
insert path = [clip even odd rule]{
[reset cm](-\maxdimen,-\maxdimen)rectangle(\maxdimen,\maxdimen)
}
}
}
\begin{document}
\centering{
A1\\
\vspace{\skiplength}
\begin{tikzpicture}[x=11.1cm, y=7.5cm]
\begin{pgfinterruptboundingbox} \clip[invclip] (2cm, 2.5cm) [rounded corners=5pt] -- (4cm, 2.5cm) -- (4cm, 0.5cm) -- (2cm, 0.5cm) -- (2cm, 2.5cm) [sharp corners] -- cycle;
\end{pgfinterruptboundingbox}
\node[anchor=south west,%
inner sep=0,%
outer sep=0pt] (image) at (0, 0) {\includegraphics[width=8cm]{example-image}};
\draw[red, line width = 4pt] (2.1cm, 2.5cm) [rounded corners=5pt] -- (4cm, 2.5cm) -- (4cm, 0.5cm) -- (2cm, 0.5cm) -- (2.cm, 2.5cm) [sharp corners] -- cycle;
\end{tikzpicture}
}
\end{document}