
答案1
環境textblock*
使用內容的屬性來決定框的大小(即使textpos
手冊聲明 的寬度textpos*
是絕對的)。 TeX 原語\hrule
將包含指令的垂直框的寬度作為寬度\hrule
(請參閱為什麼 \hrule 需要在周圍繪製文字?),在本例中為空。
可能的解決方案是使用\leavevmode
(將框的寬度設為\textwidth
,請參閱連結的問題),或手動指定寬度\hrule
,或使用\rule
具有指定寬度的命令。
下面的 MWE 提供了一些如何textpos*
處理不同類型內容的範例(使用showboxes
套件選項)。
\documentclass{beamer}
\usepackage[absolute,overlay,showboxes]{textpos}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{Demo}
\color{green}\vspace{5mm}\hrule height 1mm\vspace{5mm}
\begin{textblock*}{\textwidth}(10mm,20mm)
\vspace{2mm}\hrule height 1mm\vspace{2mm}% zero width
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,30mm)
\vspace{2mm}\leavevmode\hrule height 1mm\vspace{2mm}
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,40mm)
\color{red}\vspace{2mm}\hrule height 1mm width \textwidth\vspace{2mm}
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,50mm)
\color{blue}\rule{\textwidth}{1mm}
\end{textblock*}
%further examples of textblock*
\begin{textblock*}{\textwidth}(10mm,60mm)% width of the character
\phantom{X}
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,70mm)% does not show
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,80mm)% full width
\color{black}X
\end{textblock*}
\end{frame}
\end{document}