我正在尝试使用 TikZ 重现该图表:
到目前为止,我得到的是:
还不错,我不介意用圆圈代替省略号(反正这不是我问题的重点)……问题是:如何在三个空格内发布文本,以便 LaTeX 自动将文本强制放在这些空格内,这样如果文本很多,它甚至可以适合相同的形状?正如您所看到的预览文本,它是哈哈,指向圆圈的中心,这必然意味着位于圆圈线上。(您可以使用任何文本作为答案,例如 lipsum 等。)我当前的 Tex 代码是:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[landscape]{geometry}
\usepackage{tikz}
\usepackage{subfig}
\begin{document}
% Definition of circles
\def\firstcircle{(0,0) circle (5cm)}
\def\secondcircle{(0:5cm) circle (5cm)}
\colorlet{circle edge}{black}
\colorlet{circle area}{white}
\tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
outline/.style={draw=circle edge, thick}}
\begin{figure}
\begin{tikzpicture}
\draw
\firstcircle node(1) {$lol$}
\secondcircle node(2) {$lol$};
\node[anchor=east] at (current bounding box.west) {\huge{A}};
\node[anchor=west] at (current bounding box.east) {\huge{B}};
\node[anchor=north] at (current bounding box.south) {\huge{C}};
\end{tikzpicture}
\end{figure}
\end{document}
答案1
我建议使用\node
s 放置文本,然后使用fit
库在适当的节点周围绘制椭圆;类似这样的内容:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,fit}
\begin{document}
\begin{tikzpicture}[node distance=2cm,
every fit/.style={ellipse,ultra thick,draw,inner sep=0pt},
mytext/.style={inner sep=6pt}]
\node[mytext,align=right,rectangle] (a) {some text \\ goes here \\ and spans \\ several\\ lines};
\node[mytext,align=center,rectangle,left=of a] (b) {some text \\ goes here \\ and spans \\ several\\ lines};
\node[mytext,align=left,rectangle,left=of b] (c) {some text \\ goes here \\ and spans \\ several\\ lines};
\node[draw,fit=(a) (b)] {};
\node[draw,fit=(c) (b)] {};
\end{tikzpicture}
\end{document}
用于text width=<length>
文本节点,文本将自动换行。
答案2
类似于 Gonzalo 的方法,但在这里我修复了形状。我给矩形指定了一些尺寸,然后在矩形内放置了文本节点。小优点是固定矩形的高度。如果不这样做,并且如果一个文本高于另一个文本,则椭圆是不对称的。
\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{fit,shapes}
\begin{document}
\def\textfortest { Little text for testing}
\begin{tikzpicture}[txtstyle/.style={minimum width=3cm,minimum height=4cm,draw,inner sep=0pt}]
\node [txtstyle] (n1) {};
\node [txtstyle,xshift=-5cm] (n2) {};
\node [txtstyle,xshift= 5cm] (n3) {};
\node [ellipse,fit=(n1)(n2),draw] {};
\node [ellipse,fit=(n1)(n3),draw] {};
\begin{scope}[every node/.style={text width=3cm,anchor=north west}]
\node at (n2.north west){\textfortest. \textfortest};
\node at (n1.north west){\textfortest. \textfortest};
\node at (n3.north west){\textfortest. \textfortest};
\end{scope}
\end{tikzpicture}
\end{document}