如何在 TikZ 中分割橢圓並選擇我想要寫入的部分?

如何在 TikZ 中分割橢圓並選擇我想要寫入的部分?

我嘗試將橢圓分成兩部分(如圖所示),因為使用矩形可以輕鬆實現,但看起來效果不一樣,那麼我該怎麼做呢? (以下是我嘗試過的程式碼)

splitEllipse/.style={
    ellipse split,
    draw, 
    shape aspect=2, 
    inner sep=2pt,
    text centered,
    fill=blue!10!white,
    font=\itshape
}
splitEllipse/.style={
    ellipse split part=2,
    draw, 
    shape aspect=2, 
    inner sep=2pt,
    text centered,
    fill=blue!10!white,
    font=\itshape
}

這些代碼都不起作用。

在此輸入影像描述

答案1

您的某些選項不適用於 shape ellipse split

在此輸入影像描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\tikzset{
    splitEllipse/.style={draw, fill=blue!10!white, shape=ellipse split, align=center, minimum width=6cm, inner sep=2pt}
}

\begin{document}

\begin{tikzpicture}
\node[splitEllipse]{upper text\nodepart{lower}lower text\\second line};
\end{tikzpicture}

\end{document}

相關內容