首页 > 解决方案 > Tabularx 在 Tikz 节点中的行为不同

问题描述

我创建了一个tabularx表,当我将它放在Tikz节点中时,它的行为会有所不同。

我的目标是充分证明单元格内的文本。你会在下面找到我的 LaTeX 代码。对不起,有点杀戮,我远非专家。

谢谢。


\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\usepackage{tabularx}
\setlength{\extrarowheight}{-5pt}
\begin{document}

\section{Inside Tikz Node}
\begin{tikzpicture}[remember picture,overlay]
 
  

\node[text width=11.5cm] at (5.72, -4.5) {

\begin{tabularx}{\textwidth}{|>{\hsize=2.2cm}X>{\hsize=9cm}X}

\footnotesize{2011} & \textbf{\footnotesize{Regional Co-Manager}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{A major part of Jim Halpert's character is his relationship with Pam Beesly, which is often the subject of office speculation. This is made worse by the fact that Pam was engaged to Roy Anderson, a Dunder Mifflin warehouse worker. Throughout the first two seasons, incidents such as Pam falling asleep on Jim's shoulder in "Diversity Day" and drunkenly kissing him in "The Dundies" show a possibility of the feelings being mutual; however, Pam never acts on them and she remains engaged to Roy.}\\
\\
\hspace{-3.075mm}$\bullet$\hspace{1.7mm}\footnotesize{2005} & \textbf{\footnotesize{Sales Representative}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{Jim has two brothers; Pete, who lives in Boston, and Tom, who lives in New Jersey. They are both characterized as sharing Jim's general love of pranks but have come across as unpleasant and they somewhat bully their little brother. While Pete and Tom have been seen in several episodes, portrayed by Tug Coker, and Blake Robbins, Larissa has never been seen on screen.}\\

\end{tabularx}
};

\end{tikzpicture}

\vspace{9cm}

\section{Outside Tikz Node}

\begin{tabularx}{\textwidth}{|>{\hsize=2.2cm}X>{\hsize=9cm}X}

\footnotesize{2011} & \textbf{\footnotesize{Regional Co-Manager}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{A major part of Jim Halpert's character is his relationship with Pam Beesly, which is often the subject of office speculation. This is made worse by the fact that Pam was engaged to Roy Anderson, a Dunder Mifflin warehouse worker. Throughout the first two seasons, incidents such as Pam falling asleep on Jim's shoulder in "Diversity Day" and drunkenly kissing him in "The Dundies" show a possibility of the feelings being mutual; however, Pam never acts on them and she remains engaged to Roy.}\\
\\
\hspace{-3.075mm}$\bullet$\hspace{1.7mm}\footnotesize{2005} & \textbf{\footnotesize{Sales Representative}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{Jim has two brothers; Pete, who lives in Boston, and Tom, who lives in New Jersey. They are both characterized as sharing Jim's general love of pranks but have come across as unpleasant and they somewhat bully their little brother. While Pete and Tom have been seen in several episodes, portrayed by Tug Coker, and Blake Robbins, Larissa has never been seen on screen.}\\

\end{tabularx}


\end{document}

标签: latextabulartikz

解决方案


TikZ nodes are not justified by default, but you can make them justified by using the align=justify key:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\usepackage{tabularx}
\setlength{\extrarowheight}{-5pt}
\begin{document}

\section{Inside Tikz Node}
\begin{tikzpicture}[remember picture,overlay]
 
  

\node[text width=11.5cm,align=justify] at (5.72, -4.5) {

\begin{tabularx}{\textwidth}{|>{\hsize=2.2cm}X>{\hsize=9cm}X}

\footnotesize{2011} & \textbf{\footnotesize{Regional Co-Manager}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{A major part of Jim Halpert's character is his relationship with Pam Beesly, which is often the subject of office speculation. This is made worse by the fact that Pam was engaged to Roy Anderson, a Dunder Mifflin warehouse worker. Throughout the first two seasons, incidents such as Pam falling asleep on Jim's shoulder in "Diversity Day" and drunkenly kissing him in "The Dundies" show a possibility of the feelings being mutual; however, Pam never acts on them and she remains engaged to Roy.}\\
\\
\hspace{-3.075mm}$\bullet$\hspace{1.7mm}\footnotesize{2005} & \textbf{\footnotesize{Sales Representative}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{Jim has two brothers; Pete, who lives in Boston, and Tom, who lives in New Jersey. They are both characterized as sharing Jim's general love of pranks but have come across as unpleasant and they somewhat bully their little brother. While Pete and Tom have been seen in several episodes, portrayed by Tug Coker, and Blake Robbins, Larissa has never been seen on screen.}\\

\end{tabularx}
};

\end{tikzpicture}

\vspace{9cm}

\section{Outside Tikz Node}

\begin{tabularx}{\textwidth}{|>{\hsize=2.2cm}X>{\hsize=9cm}X}

\footnotesize{2011} & \textbf{\footnotesize{Regional Co-Manager}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{A major part of Jim Halpert's character is his relationship with Pam Beesly, which is often the subject of office speculation. This is made worse by the fact that Pam was engaged to Roy Anderson, a Dunder Mifflin warehouse worker. Throughout the first two seasons, incidents such as Pam falling asleep on Jim's shoulder in "Diversity Day" and drunkenly kissing him in "The Dundies" show a possibility of the feelings being mutual; however, Pam never acts on them and she remains engaged to Roy.}\\
\\
\hspace{-3.075mm}$\bullet$\hspace{1.7mm}\footnotesize{2005} & \textbf{\footnotesize{Sales Representative}} \\
& \textbf{\scriptsize{Dunder Mifflin, Scranton PA}}\\
& \footnotesize{Jim has two brothers; Pete, who lives in Boston, and Tom, who lives in New Jersey. They are both characterized as sharing Jim's general love of pranks but have come across as unpleasant and they somewhat bully their little brother. While Pete and Tom have been seen in several episodes, portrayed by Tug Coker, and Blake Robbins, Larissa has never been seen on screen.}\\

\end{tabularx}


\end{document}

enter image description here


推荐阅读