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.

My goal is to get text in a node closer.

Here is how it should be done: Look at XXXXXXXXXXX node.

enter image description here

\documentclass{beamer}%
\mode<presentation>%
{
\usetheme{Madrid}%
\setbeamercovered{transparent}
}

\makeatletter
   \newcommand\myFont{\@setfontsize\myFont{6pt}{7}}
\makeatother

\usepackage[utf8x]{inputenc}
\usepackage[MeX]{polski}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{%
  arrows,%
  shapes.misc,%
  shapes.arrows,%
  positioning,% wg. " of "
  scopes,%
  decorations.pathmorphing,%
  shadows%
}

\usepackage{amsmath}
\usepackage{tgheros}
\renewcommand*\familydefault{\sfdefault} 

\title[Example]%
{\textbf{How to get better leading in node}} %
\subtitle{}%
\author[]%
{Foo Bar}%
\institute[of Beamer]%
{ 
%
}
\date[\today]%
{}%

\subject{Talks}%

\definecolor{niebieski}{HTML}{aac9cb}
\definecolor{szary}{HTML}{7a7a7a}

\tikzstyle{kwadrat}=[rectangle, rounded corners=2pt, thin, black,top color=white, bottom color=niebieski, draw=szary, text= black, minimum width=2.5cm, minimum height=0.5cm, drop shadow, text width = 2.5cm, text badly centered, inner ysep=-2pt, ]

\begin{document}
\begin{frame}
{\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny d};
     \node[kwadrat, right of=m1] (p1){\tiny c};
     \node[kwadrat, right of=p1] (k1) {\tiny b};
     \node[kwadrat, right of=k1] (a1) {\tiny a};
 \end{tikzpicture}
 \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat, below of=m1](m2){\tiny D};
     \node[kwadrat, right of=m2] (p2){\tiny C};
     \node[kwadrat, right of=p2] (k2) {\tiny THE PROBLEM IS HERE TOO MUCH SPACE BETWEEN LINES OF TEXT};
     \end{tikzpicture}
  \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
  \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny A};
     \node[kwadrat, right of=m1] (p1){\tiny B};
     \node[kwadrat, right of=p1] (k1) {\tiny C};
     \node[kwadrat, right of=k1] (a1) {\tiny D};
  \end{tikzpicture}

 \end{frame}
 \end{document}
share|improve this question
1  
You can say \parbox{2.5cm}{\tiny ...}, but three lines won't fit anyway. Maybe with \fontsize{4}{5}\selectfont instead of \tiny. –  egreg Oct 29 '12 at 23:07
add comment

1 Answer

up vote 4 down vote accepted

You can use a \parbox:

\documentclass{beamer}%
\mode<presentation>%
{
\usetheme{Madrid}%
\setbeamercovered{transparent}
}

\makeatletter
   \newcommand\myFont{\@setfontsize\myFont{6pt}{7}}
\makeatother

\usepackage[utf8x]{inputenc}
\usepackage[MeX]{polski}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{%
  arrows,%
  shapes.misc,%
  shapes.arrows,%
  positioning,% wg. " of "
  scopes,%
  decorations.pathmorphing,%
  shadows%
}

\usepackage{amsmath}
\usepackage{tgheros}
\renewcommand*\familydefault{\sfdefault} 

\title[Example]%
{\textbf{How to get better leading in node}} %
\subtitle{}%
\author[]%
{Foo Bar}%
\institute[of Beamer]%
{ 
%
}
\date[\today]%
{}%

\subject{Talks}%

\definecolor{niebieski}{HTML}{aac9cb}
\definecolor{szary}{HTML}{7a7a7a}

\tikzstyle{kwadrat}=[rectangle, rounded corners=2pt, thin, black,top color=white, bottom color=niebieski, draw=szary, text= black, minimum width=2.5cm, minimum height=0.5cm, drop shadow, text width = 2.5cm, text badly centered, inner ysep=-2pt, ]

\begin{document}
\begin{frame}
{\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny d};
     \node[kwadrat, right of=m1] (p1){\tiny c};
     \node[kwadrat, right of=p1] (k1) {\tiny b};
     \node[kwadrat, right of=k1] (a1) {\tiny a};
 \end{tikzpicture}
 \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat, below of=m1](m2){\tiny D};
     \node[kwadrat, right of=m2] (p2){\tiny C};
     \node[kwadrat, right of=p2] (k2) {\parbox{2.5cm}{\tiny SOME TEXT HERE SPANNING TWO LINES}};
     \end{tikzpicture}
  \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
  \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny A};
     \node[kwadrat, right of=m1] (p1){\tiny B};
     \node[kwadrat, right of=p1] (k1) {\tiny C};
     \node[kwadrat, right of=k1] (a1) {\tiny D};
  \end{tikzpicture}

 \end{frame}
 \end{document}

enter image description here

As egreg mentioned in his comment, instead of \tiny, you can use a smaller font size using \fontsize{...}{...}\selectfont:

\documentclass{beamer}%
\mode<presentation>%
{
\usetheme{Madrid}%
\setbeamercovered{transparent}
}

\makeatletter
   \newcommand\myFont{\@setfontsize\myFont{6pt}{7}}
\makeatother

\usepackage[utf8x]{inputenc}
\usepackage[MeX]{polski}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{%
  arrows,%
  shapes.misc,%
  shapes.arrows,%
  positioning,% wg. " of "
  scopes,%
  decorations.pathmorphing,%
  shadows%
}

\usepackage{amsmath}
\usepackage{tgheros}
\renewcommand*\familydefault{\sfdefault} 

\title[Example]%
{\textbf{How to get better leading in node}} %
\subtitle{}%
\author[]%
{Foo Bar}%
\institute[of Beamer]%
{ 
%
}
\date[\today]%
{}%

\subject{Talks}%

\definecolor{niebieski}{HTML}{aac9cb}
\definecolor{szary}{HTML}{7a7a7a}

\tikzstyle{kwadrat}=[rectangle, rounded corners=2pt, thin, black,top color=white, bottom color=niebieski, draw=szary, text= black, minimum width=2.5cm, minimum height=0.5cm, drop shadow, text width = 2.5cm, text badly centered, inner ysep=-2pt, ]

\begin{document}
\begin{frame}
{\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny d};
     \node[kwadrat, right of=m1] (p1){\tiny c};
     \node[kwadrat, right of=p1] (k1) {\tiny b};
     \node[kwadrat, right of=k1] (a1) {\tiny a};
 \end{tikzpicture}
 \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat, below of=m1](m2){\tiny D};
     \node[kwadrat, right of=m2] (p2){\tiny C};
     \node[kwadrat, right of=p2] (k2) {\parbox{2.5cm}{\fontsize{4}{4}\selectfont\centering SOME TEXT HERE SPANNING THREE LINES OF TEXT JUST FOR THIS SHORT EXAMPLE}};
     \end{tikzpicture}
  \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
  \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny A};
     \node[kwadrat, right of=m1] (p1){\tiny B};
     \node[kwadrat, right of=p1] (k1) {\tiny C};
     \node[kwadrat, right of=k1] (a1) {\tiny D};
  \end{tikzpicture}

 \end{frame}
 \end{document}

enter image description here

Perhaps you can also consider increasing a little the height of the nodes:

\documentclass{beamer}%
\mode<presentation>%
{
\usetheme{Madrid}%
\setbeamercovered{transparent}
}

\makeatletter
   \newcommand\myFont{\@setfontsize\myFont{6pt}{7}}
\makeatother

\usepackage[utf8x]{inputenc}
\usepackage[MeX]{polski}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{%
  arrows,%
  shapes.misc,%
  shapes.arrows,%
  positioning,% wg. " of "
  scopes,%
  decorations.pathmorphing,%
  shadows%
}

\usepackage{amsmath}
\usepackage{tgheros}
\renewcommand*\familydefault{\sfdefault} 

\title[Example]%
{\textbf{How to get better leading in node}} %
\subtitle{}%
\author[]%
{Foo Bar}%
\institute[of Beamer]%
{ 
%
}
\date[\today]%
{}%

\subject{Talks}%

\definecolor{niebieski}{HTML}{aac9cb}
\definecolor{szary}{HTML}{7a7a7a}

\tikzstyle{kwadrat}=[rectangle, rounded corners=2pt, thin, black,top color=white, bottom color=niebieski, draw=szary, text= black, minimum width=2.5cm, minimum height=0.6cm, drop shadow, text width = 2.5cm, text badly centered, inner ysep=-2pt, ]

\begin{document}
\begin{frame}
{\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny d};
     \node[kwadrat, right of=m1] (p1){\tiny c};
     \node[kwadrat, right of=p1] (k1) {\tiny b};
     \node[kwadrat, right of=k1] (a1) {\tiny a};
 \end{tikzpicture}
 \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
 \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat, below of=m1](m2){\tiny D};
     \node[kwadrat, right of=m2] (p2){\tiny C};
     \node[kwadrat, right of=p2] (k2) {\parbox{2.5cm}{\fontsize{4}{5}\selectfont\centering SOME TEXT HERE SPANNING THREE LINES OF TEXT JUST FOR THIS SHORT EXAMPLE}};
     \end{tikzpicture}
  \vspace{10pt}

 {\myFont \textbf{SOME TEXT}}
  \vspace{2pt}

 \begin{tikzpicture}[node distance=3cm]
     \node[kwadrat,](m1){\tiny A};
     \node[kwadrat, right of=m1] (p1){\tiny B};
     \node[kwadrat, right of=p1] (k1) {\tiny C};
     \node[kwadrat, right of=k1] (a1) {\tiny D};
  \end{tikzpicture}

 \end{frame}
 \end{document}

enter image description here

share|improve this answer
    
Dosent work correct for long text [3 lines]. Each line must be next to another. As close as possible. \parbox leave space. What next then? –  Daniel Miliński Oct 29 '12 at 23:12
1  
@DanielMiliński please see my updated answer. –  Gonzalo Medina Oct 29 '12 at 23:15
1  
@DanielMiliński new update. –  Gonzalo Medina Oct 29 '12 at 23:22
    
Works great! Thank You! –  Daniel Miliński Oct 29 '12 at 23:43
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.