在 tikzpicture 文本框中对齐文本

在 tikzpicture 文本框中对齐文本

我试图在 tikzpicture 中放置一个文本框,并使用了以下行

\node[text width=15.5cm] at (0,-2) {One fān is awarded for every kè zi or gàng zi of a fān pái present in the hand.  If the mén fēng and quān fēng coincide, then a kè zi or gàng zi of this is awarded two fān instead.} ;

这样做,但发现文本在“文本框”中没有对齐。 有没有什么方法可以对齐文本?

答案1

添加align=justify到节点选项即可实现这一点。但文本仅覆盖两行文本,因此第二行不会填满整行。(它不应该这样,否则看起来很糟糕。)我不认为这种特定行为与 TikZ 有任何关系,它只是 TeX 的工作方式。

具有两个较窄节点的示例。我添加了draw节点边界,以便您能够看到。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\begin{document}
Without \texttt{align=justify}:

\tikz \node[draw, text width=5cm] at (0,-2) {One fān is awarded for every kè zi or gàng zi of a fān pái present in the hand.  If the mén fēng and quān fēng coincide, then a kè zi or gàng zi of this is awarded two fān instead.} ;

With \texttt{align=justify}:

\tikz \node[draw, text width=5cm, align=justify] at (0,-2) {One fān is awarded for every kè zi or gàng zi of a fān pái present in the hand.  If the mén fēng and quān fēng coincide, then a kè zi or gàng zi of this is awarded two fān instead.} ;


With a wide node:

\tikz \node[draw, text width=15.5cm, align=justify] at (0,-2) {One fān is awarded for every kè zi or gàng zi of a fān pái present in the hand.  If the mén fēng and quān fēng coincide, then a kè zi or gàng zi of this is awarded two fān instead.} ;

\end{document}

答案2

文本的对齐/排列没有问题。

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[text width=15.5cm] at (0,-2) {One fān is awarded for every kè zi or gàng 
zi of a fān pái present in the hand.  If the mén fēng and quān fēng coincide, 
then a kè zi or gàng zi of this is awarded two fān instead.};
\end{tikzpicture}
\end{document}[![enter image description here][1]][1]

在此处输入图片描述

相关内容