我正在绘制一个分成两部分的矩形:
\documentclass[runningheads,orivec]{llncs}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\begin{document}
\tikzstyle{abstract}=[rectangle, draw=black, rounded corners, fill=white!20, drop shadow,
text centered, anchor=north, text=black, text width=3cm, scale=0.8]
\begin{figure}[H]
\centering
\begin{tikzpicture}[node distance=1cm,]
\node(domain) [abstract, rectangle split, rectangle split parts=2, text width=7cm, text height = 0.1cm, text justified]
{
\begin{center}hehe\end{center}
\nodepart{second}haha
};
\end{tikzpicture}
\end{figure}
\end{document}
第一部分只有“呵呵”,但是高度太多了...text height = 0.1cm
好像不行...有谁知道怎样把第一部分的高度降低,让它根据文字调整吗?
答案1
我将使用 来text node part
使文本居中。
\documentclass[runningheads,orivec]{llncs}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\begin{document}
\tikzstyle{abstract}=[rectangle, draw=black, rounded corners, fill=white!20, drop shadow,
text centered, anchor=north, text=black, text width=3cm, scale=0.8]
\begin{figure}[H]
\centering
\begin{tikzpicture}[node distance=1cm,]
\node(domain) [abstract, rectangle split,
every text node part/.style={align=center},
rectangle split parts=2,
text width=7cm,
text height = 0.1cm,
text justified]
{
hehe
\nodepart{second}haha
};
\end{tikzpicture}
\end{figure}
\end{document}
答案2
您可以使用 \centering 代替 \center
\documentclass{文章} \usepackage{tikz} \usetikzlibrary{定位、形状、阴影、箭头} \开始{文档} \tikzstyle{abstract}=[矩形,绘制=黑色,圆角,填充=白色!20,阴影, 文本居中,锚点=北,文本=黑色,文本宽度=3cm,比例=0.8] \begin{图}[H] \定心 \begin{tikzpicture}[节点距离=1cm,] \node(domain) [摘要,矩形分割,矩形分割部分=2,文本宽度=7cm,文本高度=0.1cm,文本对齐] { \begin{center}呵呵\end{center} \nodepart{second}哈哈 }; \结束{tikzpicture} \结束{图} \begin{图}[H] \定心 \begin{tikzpicture}[节点距离=1cm,] \node(domain) [摘要,矩形分割,矩形分割部分=2,文本宽度=7cm,文本高度=0.1cm,文本对齐] { \centering 呵呵\par \nodepart{second}哈哈 }; \结束{tikzpicture} \结束{图} \结束{文档}
答案3
您还可以独立地提供选项nodepart
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows}
\tikzset{abstract/.style={
rectangle,
draw=black,
rounded corners,
fill=white!20,
drop shadow,
text centered,
anchor=north,
text=black,
text width=3cm,
text width=7cm,
scale=0.8
}
}
\begin{document}
\begin{tikzpicture}
\node(domain) [abstract, rectangle split, rectangle split parts=2 ]
{
hehe
\nodepart[text justified]{second} haha
};
\end{tikzpicture}
\end{document}