4

It seems that verbatim is not working properly. It produce an error and the output is not as I expected. Here is the latex code

% !TEX encoding = UTF-8 Unicode
\documentclass{beamer}

\mode<presentation>
\usetheme{Madrid}
\setbeamercovered{transparent}

\usepackage{beamerthemesplit}
\usepackage[utf8]{inputenc}
\usepackage{graphics}
\usepackage{graphicx} 
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{natbib} 
\usepackage[turkish]{babel}
\usepackage{verbatim}
\AtBeginDocument{\catcode`==12 }

\begin{document}
\begin{frame}

\begin{verbatim}

Call:
glm(formula = propn.dead ~ conc, family = binomial(link = logit), 
    weights = number)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.5941  -0.3944   0.8329   1.2592   1.5940  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -60.717      5.181  -11.72   <2e-16 ***
conc          34.270      2.912   11.77   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 284.202  on 7  degrees of freedom
Residual deviance:  11.232  on 6  degrees of freedom
AIC: 41.43

Number of Fisher Scoring iterations: 4
\end{verbatim}
\end{frame}
\end{document}

enter image description here

  • 1
    Add fragile option to the frame – percusse Oct 24 '14 at 17:31
  • Have never used it before. Can you please give me the code? – Günal Oct 24 '14 at 17:36
  • 2
    I think @percusse means \begin{frame}[fragile] and \end{frame}. – mickep Oct 24 '14 at 17:38
  • Or use beamer's own semivarbatim environment instead of verbatim, as in \begin{ssemiverbatim}...\end{semiverbatim}. – Gonzalo Medina Oct 24 '14 at 18:16
4

The error is because you have to declare the frame as [fragile] due to the presence of verbatim code.

To get a good fit you can reduce the size of the font and you can use another font. To reduce the size of the font you can use \footnotesize or \scriptsize in the frame. If you add \usepackage[scaled]{beramono} to the preamble it will use the beramono font for the monospaced fonts used in verbatim. The beramono use less space than the default monospaced font.

Look the images below the difference.

Using default font and \footnotesize

enter image description here

Using Beramono font and \footnotesize

enter image description here

The Modified Code

Here is the code using beramono font and \footnotesize (produces the second image)

% !TEX encoding = UTF-8 Unicode
\documentclass{beamer}

\mode<presentation>
\usetheme{Madrid}
\setbeamercovered{transparent}

\usepackage{beamerthemesplit}
\usepackage[utf8]{inputenc}
\usepackage{graphics}
\usepackage{graphicx} 
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{natbib} 
\usepackage[turkish]{babel}
\usepackage{verbatim}
\AtBeginDocument{\catcode`==12 }

\usepackage[scaled]{beramono} %sets the beramono font. Just comment this line to get the default font back

\begin{document}
\begin{frame}[fragile]
\footnotesize %change the font size. You can \scriptsize to get a smaller font.
\begin{verbatim}
Call:
glm(formula = propn.dead ~ conc, family = binomial(link = logit), 
    weights = number)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.5941  -0.3944   0.8329   1.2592   1.5940  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -60.717      5.181  -11.72   <2e-16 ***
conc          34.270      2.912   11.77   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 284.202  on 7  degrees of freedom
Residual deviance:  11.232  on 6  degrees of freedom
AIC: 41.43

Number of Fisher Scoring iterations: 4
\end{verbatim}
\end{frame}
\end{document}

It´s a matter of your personal taste now. :-)

3

In addition to specifying the option [fragile] when starting the frame, you will need to issue the command \scriptsize -- for a 30% linear reduction in font size -- in order to make the verbatim material fit in the frame.

enter image description here

% !TEX encoding = UTF-8 Unicode
\documentclass{beamer}

\mode<presentation>
\usetheme{Madrid}
\setbeamercovered{transparent}

\usepackage{beamerthemesplit}
\usepackage[utf8]{inputenc}
%%\usepackage{graphics}
\usepackage{graphicx} 
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{natbib} 
\usepackage[turkish]{babel}
\usepackage{verbatim}
\AtBeginDocument{\catcode`==12 }

\begin{document}
\begin{frame}[fragile] %% option "fragile" is new
\scriptsize  %%  new instruction
\begin{verbatim}

Call:
glm(formula = propn.dead ~ conc, family = binomial(link = logit), 
    weights = number)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.5941  -0.3944   0.8329   1.2592   1.5940  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -60.717      5.181  -11.72   <2e-16 ***
conc          34.270      2.912   11.77   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 284.202  on 7  degrees of freedom
Residual deviance:  11.232  on 6  degrees of freedom
AIC: 41.43

Number of Fisher Scoring iterations: 4
\end{verbatim}
\end{frame}
\end{document}
  • 1
    +1. Another option (that I just suggested in a comment to the question) is to use beamer's own semiverbatim instead of verbatim; the former doesn't require an explicit fragile for the frame. – Gonzalo Medina Oct 24 '14 at 18:18
  • @GonzaloMedina - Thanks. I just tried out semiverbatim, am I'm afraid the output looks awful for the case at hand if fragile is not specified as well. (Basically, semiverbatim without fragile seems to ignore line breaks that aren't immediately followed by a second line break.) Since semiverbatim differs from verbatim only in the treatment of {, }, and \ , there would seem to be little advantage in the present situation, right? – Mico Oct 24 '14 at 18:21
  • Yes, you're right. Both verbatim and semiverbatim are very basic verbatim environments; an option using the powerful listings package could be a better possibility here. – Gonzalo Medina Oct 24 '14 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.