![如何更改节点中的文本行距](https://linux22.com/image/257709/%E5%A6%82%E4%BD%95%E6%9B%B4%E6%94%B9%E8%8A%82%E7%82%B9%E4%B8%AD%E7%9A%84%E6%96%87%E6%9C%AC%E8%A1%8C%E8%B7%9D.png)
我的目标是让节点中的文本更接近。
应该这样做:查看 XXXXXXXXXXX 节点。
\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}
答案1
您可以使用\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}
作为埃格尔在他的评论中提到,\tiny
您可以使用较小的字体大小,而不是\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}
也许您还可以考虑稍微增加节点的高度:
\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}