%20%E5%86%85%E3%81%AE%20%5Chrule%20%E3%81%AF%E5%87%BA%E5%8A%9B%E3%81%AB%E8%A1%A8%E7%A4%BA%E3%81%95%E3%82%8C%E3%81%BE%E3%81%9B%E3%82%93.png)
私のコード:
\documentclass{beamer}
\usepackage[absolute,overlay]{textpos}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{Demo}
\begin{textblock*}{\textwidth}(20mm,20mm)
\vspace{5mm}\hrule height 1mm\vspace{5mm}
\end{textblock*}
\end{frame}
\end{document}
出力:
\hrule
出力に が表示されないのはなぜですか? どうすれば修正できますか?
答え1
環境textblock*
は、コンテンツのプロパティを使用してボックスのサイズを決定します(マニュアルではtextpos
幅はtextpos*
絶対であると記載されていますが)。TeXプリミティブは、命令\hrule
を囲む垂直ボックスの幅を幅として取得します\hrule
(\hrule を描画するにはなぜ周囲にテキストが必要なのでしょうか?)、この場合は空です。
考えられる解決策としては\leavevmode
、 (ボックスの幅を に設定します。\textwidth
リンクされた質問を参照) を使用するか、 の幅を\hrule
手動で指定するか、幅を指定して コマンドを使用することです\rule
。
textpos*
以下に MWE を示します。説明のために、さまざまな種類のコンテンツを処理する方法の例をいくつか示します(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}