Notebook

これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。

HTML ファイル生成日時: 2025/11/23 20:31:30.065 (台灣標準時)

Beamer で verbatim 環境を使う方法

Beamer では、そのままだと verbatim 環境を使えないようでござる。以下の ようなファイルを用意し、 LaTeX を実行してみると、コンパイルできない。


\documentclass[t]{beamer}

\begin{document}

 \begin{frame}{Test of verbatim}
\begin{verbatim}
879.2886783554586
917.3192566724524
913.1680734270184
926.212581516465
931.0554662200888
893.9903129038346
838.540154200455
949.2957743797285
1024.7504166673
997.2277092482291

.....
\end{verbatim}
 \end{frame}

\end{document}

実行してみると、以下のようになる。


% latex test.tex 
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/pkgsrc) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-06-01>
(/usr/pkg/share/texmf-dist/tex/latex/beamer/beamer.cls
Document Class: beamer 2021/05/26 v3.63 A class for typesetting presentations
(/usr/pkg/share/texmf-dist/tex/latex/beamer/beamerbasemodes.sty
(/usr/pkg/share/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/pkg/share/texmf-dist/tex/latex/beamer/beamerbasedecode.sty))

.....

(/usr/pkg/share/texmf-dist/tex/latex/translator/translator-months-dictionary-En
glish.dict)
(/usr/pkg/share/texmf-dist/tex/latex/translator/translator-numbers-dictionary-E
nglish.dict)
(/usr/pkg/share/texmf-dist/tex/latex/translator/translator-theorem-dictionary-E
nglish.dict)
No file test.nav.
Runaway argument?
 879.2886783554586 917.3192566724524 913.1680734270184 926.2125815164\ETC.
! Paragraph ended before \@xverbatim was complete.
 
                   \par 
l.20  \end{frame}
                 
? 

Beamer で verbatim 環境を使うには、 frame 環境に fragile オプションを 与えればよいようでござる。以下のように変更するとコンパイルできるように なるようでござる。


\documentclass[t]{beamer}

\begin{document}

 \begin{frame}[fragile]{Test of verbatim}
\begin{verbatim}
879.2886783554586
917.3192566724524
913.1680734270184
926.212581516465
931.0554662200888
893.9903129038346
838.540154200455
949.2957743797285
1024.7504166673
997.2277092482291

.....
\end{verbatim}
 \end{frame}

\end{document}

コンパイルしてみると、以下のように問題なくコンパイルが完了する。


% latex test2.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/pkgsrc) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./test2.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-06-01>
(/usr/pkg/share/texmf-dist/tex/latex/beamer/beamer.cls
Document Class: beamer 2021/05/26 v3.63 A class for typesetting presentations
(/usr/pkg/share/texmf-dist/tex/latex/beamer/beamerbasemodes.sty
(/usr/pkg/share/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/pkg/share/texmf-dist/tex/latex/beamer/beamerbasedecode.sty))

.....

(/usr/pkg/share/texmf-dist/tex/latex/translator/translator-months-dictionary-En
glish.dict)
(/usr/pkg/share/texmf-dist/tex/latex/translator/translator-numbers-dictionary-E
nglish.dict)
(/usr/pkg/share/texmf-dist/tex/latex/translator/translator-theorem-dictionary-E
nglish.dict)
No file test2.nav.
(./test2.vrb) [1] (./test2.aux) )
Output written on test2.dvi (1 page, 23016 bytes).
Transcript written on test2.log.



Frequently accessed files

  1. Misc___Taiwan/20240207_00.html
  2. Computer___TeX/20231107_00.html
  3. Computer___TeX/20230726_01.html
  4. Misc___Taiwan/20240819_00.html
  5. Misc___Taiwan/20240903_01.html
  6. Computer___NetBSD/20250307_00.html
  7. Computer___TeX/20240411_00.html
  8. Misc___Japan/20240718_00.html
  9. Computer___Network/20251123_00.html
  10. Computer___Network/20240130_00.html
  11. Computer___Hardware/20240820_00.html
  12. Computer___Network/20240416_00.html
  13. Book___Chinese/20240424_00.html
  14. Computer___Python/20220715_0.html
  15. Computer___NetBSD/20240101_02.html
  16. Computer___NetBSD/20220506_0.html
  17. Computer___NetBSD/20240805_03.html
  18. Computer___Python/20210204_1.html
  19. Computer___NetBSD/20230119_00.html
  20. Computer___NetBSD/20230121_00.html
  21. Computer___Network/20231225_00.html
  22. Computer___TeX/20240410_00.html
  23. Computer___TeX/20240414_00.html
  24. Computer___NetBSD/20241223_00.html
  25. Misc___Taiwan/20210215_0.html
  26. Computer___NetBSD/20240810_00.html
  27. Food___Taiwan/20230622_27.html
  28. Food___Taiwan/20220830_5.html
  29. Computer___Network/20241214_00.html
  30. Food___Taiwan/20230622_13.html


HTML file generated by Kinoshita Daisuke.