Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am drawing a rectangle which is split into 2 parts:

\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}

There is just "hehe" in the first part, but the height is too much... text height = 0.1cm does not seem to work... Does anyone know how to reduce the height of the first part, let it adjusted in according to the text?

share|improve this question
1  
\hfil hehe \hfil –  Alain Matthes Mar 2 '12 at 7:13
add comment

3 Answers

you can use \centering instead of \center


\documentclass{article}
\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}

\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]
    {
      \centering hehe\par   
      \nodepart{second}haha
    };
  \end{tikzpicture}
\end{figure}
\end{document}


share|improve this answer
add comment

I'd use the text node part to center the text.

\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}
share|improve this answer
    
yes it's the natural way ! the trick is that the OP must avoid \begin{center}hehe\end{center} –  Alain Matthes Mar 2 '12 at 9:36
add comment

You can also give options to the nodepart independently.

\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}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.