我正在使用 venndiagram2sets 包,并且大多数情况下我能够使用模式:
\documentclass[10pt,twoside,openright]{memoir}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{venndiagram}
\begin{document}
\begin{venndiagram2sets}
[tikzoptions={scale=.7, thick},labelNotAB={},labelA={},labelB={},shade={}, showframe=False]
\begin{scope}[every path/.append style={pattern=north east lines}]
\fillA
\end{scope}
\begin{scope}[every path/.append style={pattern=north west lines}]
\fillB
\end{scope}
\draw (0,2.7) node {{A}};
\draw (5,2.7) node {{B}};
\draw (2.5,0) node {{AB}};
\end{venndiagram2sets}
\begin{venndiagram2sets}
[tikzoptions={scale=.7, thick},labelNotAB={},labelA={},labelB={},shade={}, showframe=False]
\begin{scope}[every path/.append style={pattern=north east lines}]
\fillANotB
\end{scope}
\draw (0,2.7) node {{A}};
\draw (5,2.7) node {{B}};
\draw (2.5,0) node {{AB}};
\end{venndiagram2sets}
\begin{venndiagram2sets}
[tikzoptions={scale=.7, thick},labelNotAB={},labelA={},labelB={},shade={}, showframe=False]
\begin{scope}[every path/.append style={pattern=north west lines}]
\fillBNotA
\end{scope}
\draw (0,2.7) node {{A}};
\draw (5,2.7) node {{B}};
\draw (2.5,0) node {{AB}};
\end{venndiagram2sets}
% \begin{venndiagram2sets}
% [tikzoptions={scale=.7, thick},labelNotAB={},labelA={},labelB={},shade={}, showframe=False]
% \begin{scope}[every path/.append style={pattern=north east lines}]
% \fillACapB
% \end{scope}
% \draw (0,2.7) node {{A}};
% \draw (5,2.7) node {{B}};
% \draw (2.5,0) node {{AB}};
% \end{venndiagram2sets}
\end{document}
但它不适用于最后一种情况:
\begin{venndiagram2sets}
[tikzoptions={scale=.7, thick},labelNotAB={},labelA={},labelB={},shade={}, showframe=False]
\begin{scope}[every path/.append style={pattern=crosshatched}]
\fillACapB
\end{scope}
\draw (2.5,0) node {{AB}};
\end{venndiagram2sets}
错误:
! Package tikz Error: Extra options not allowed for clipping path command..
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.700 \fillACapB
如何在 venndiagram 中的交叉点添加交叉影线图案?
答案1
我按照上一个问题的代码添加了没有标签的第一步......
您可以看到它的\ofillACapB
工作。我留给您使用\begin{tikzpicture}
和\end{tikzpicture}
设置环境来放置一个漂亮的标签{venndiagram2sets}
。最后,您可以在数学模式下使用$\scriptstyle a=B$
,而不是\tiny
在文本模式下使用。
%% Compile and read me!
\documentclass[a4paper,12pt]{article}
\usepackage{venndiagram,tikz}
\usepackage{amsmath}
\usetikzlibrary{patterns}
\newcommand*\wrapscope[1]{%
\expandafter\newcommand\csname o#1\endcsname[1][]{%
\begin{scope}[##1]
\csname #1\endcsname
\end{scope}
}%
}%
\wrapscope{fillA}
\wrapscope{fillACapB}
\makeatletter
\tikzset{
clip/.append code={%
\let\tikz@options=\pgfutil@empty
\tikz@addmode\tikz@mode@fillfalse%
\tikz@addmode\tikz@mode@drawfalse%
\tikz@addmode\tikz@mode@doublefalse%
\tikz@addmode\tikz@mode@boundaryfalse%
\tikz@addmode\tikz@mode@fade@pathfalse%
\tikz@addmode\tikz@mode@fade@scopefalse%
}
}
\makeatother
\begin{document}
\begin{venndiagram2sets}[tikzoptions={scale=.7, thick},labelNotAB={},labelA={},labelB={},shade={}, showframe=False]
\begin{scope}[every path/.append style={pattern=north east lines}]
\ofillACapB
\end{scope}
\end{venndiagram2sets}
\end{document}