投影仪框架中的逐字问题

投影仪框架中的逐字问题

看起来它verbatim不能正常工作。它会产生错误,并且输出结果与我的预期不符。以下是 latex 代码

% !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}

在此处输入图片描述

答案1

该错误是因为您必须将框架声明为[fragile]由于存在逐字代码而导致的。

为了获得良好的适配,您可以减小字体大小,也可以使用其他字体。要减小字体大小,您可以在框架中使用\footnotesize或。如果您添加到序言中,它将使用 beramono 字体作为逐字使用的等宽字体。beramono 使用的空间比默认的等宽字体要小。\scriptsize\usepackage[scaled]{beramono}

看一下下面的图片来了解区别。

使用默认字体和\footnotesize

在此处输入图片描述

使用 Beramono 字体和\footnotesize

在此处输入图片描述

修改后的代码

这是使用 beramono 字体的代码\footnotesize(生成第二张图片)

% !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}

现在这取决于你的个人品味。:-)

答案2

除了[fragile]在启动时指定选项之外frame,您还需要发出命令\scriptsize- 将字体大小线性减少 30% - 以使逐字材料适合框架。

在此处输入图片描述

% !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}

相关内容