水平对齐两个 \PsTextFrames 的文本

水平对齐两个 \PsTextFrames 的文本

假设我有两个\PsTextFrames共享 y 坐标但具有不同 x 坐标的图形,如下所示:

\documentclass{article}
\usepackage{fontspec}
\usepackage{pst-all}

\begin{document}

\begin{pspicture}(0,0)(5,2)
    \psset{linewidth=1pt}
    \psTextFrame(0.5,0.5)(2.5,1.5){\large\textbf{Left}}
    \psTextFrame(1.5,0.5)(3.5,1.5){\large\textbf{Right}}    
\end{pspicture}
\end{document}

有没有可能让它们的字母水平对齐?»Ri 中的字母 »g«Ght« 使整个单词上升,因为它有一个 »cellar«。在 »Left« 中没有字母带有 »cellar«。这样的单个实例可以手动完成,但我有一个更大的图片,其中有更多框架挂在一起。一次性更改它们将是可行的。

在此处输入图片描述

答案1

作为一种解决方法,您可以修补\psTextFrame命令以包含垂直幻影字符,以确保每个框架具有相同的高度。垂直幻影字符是宽度为零的字符(因此不会以任何方式打印或添加到 pdf 中),但仍分配了字符的高度,因此 LaTeX 会使框在垂直方向上变大。

梅威瑟:

\documentclass{article}
\usepackage{pst-all}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\psTextFrame@i}{#3}{\vphantom{Xq}#3}{}{}
\makeatother

\begin{document}
\begin{pspicture}(0,0)(5,2)
    \psset{linewidth=1pt}
    \psTextFrame(0.5,0.5)(2.5,1.5){\large\textbf{Left}}
    \psTextFrame(1.5,0.5)(3.5,1.5){\large\textbf{Right}}    
\end{pspicture}
\end{document}

结果:

在此处输入图片描述

相关内容