微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Tabularx在Tikz节点内的行为有所不同

如何解决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,Larissa has never been seen on screen.}\\

\end{tabularx}


\end{document}

解决方法

TikZ节点默认情况下不合理,但是您可以使用align=justify键使它们合理:

\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,Larissa has never been seen on screen.}\\

\end{tabularx}


\end{document}

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。