考虑以下 MWE,它生成下面的维恩图:
\documentclass[12pt]{article}
\usepackage{tikz,pstricks,pst-jtree}
% pst-jtree enables the \multiline \cr \endmultiline syntax
\usetikzlibrary{shapes,backgrounds}
\begin{document}
\begin{center}
\begin{center}
\def\first{(0,0) ellipse (6em and 4em)}
\def\second{(2.7,0) ellipse (6em and 4em)}
\def\third{(1.45,1.5) ellipse (6em and 4em)}
\begin{tikzpicture}
\draw \first node [below] { };
\draw \second node [below] { };
\draw \third node [above] { };
% first coordinate control x axis, second controls y axis
\node at (-1.1,-.3) (A) {first};
\node at (3.8,-.5) (B) {second};
\node at (2.1,.8) (C) {\multiline we care\cr about this\endmultiline};
\node at (1.5,2.5) (C) {third};
\begin{scope}[fill opacity = .5]
\clip \third;
\fill[light-gray] \second;
\end{scope}
\end{tikzpicture}
\end{center}
\end{center}
\end{document}
出于美观原因,我不希望椭圆的线条first
干扰we care about this
图例。是否可以消除first
阴影区域中的圆弧?
答案1
只需改变绘制顺序:
- 第一个椭圆
- 灰色地带
- 第二和第三个省略号和文本节点。
进一步说明:
通过节点选项启用多行文本
align
。light-gray
由于连字符,颜色名称有点不令人满意。当\fill[light-gray]
使用简写符号时,如果颜色未定义(如问题示例中所示),TikZ 会将连字符误解为箭头规范。TikZ 会抱怨未知的箭头尖,light
而不是未定义的颜色错误fill=light-gray
或未知的键。
示例文件:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{center}
\def\first{(0,0) ellipse (6em and 4em)}
\def\second{(2.7,0) ellipse (6em and 4em)}
\def\third{(1.45,1.5) ellipse (6em and 4em)}
\begin{tikzpicture}
\draw \first node [below] { };
\begin{scope}
\clip \third;
\fill[lightgray] \second;
\end{scope}
\draw \second node [below] { };
\draw \third node [above] { };
% first coordinate control x axis, second controls y axis
\node at (-1.1,-.3) (A) {first};
\node at (3.8,-.5) (B) {second};
\node[align=center] at (2.1,.8) (C) {we care\\ about this};
\node at (1.5,2.5) (C) {third};
\end{tikzpicture}
\end{center}
\end{document}