逐字和图表并列

逐字和图表并列

我正在尝试将图像放在逐字旁边:

\documentclass[a4paper]{article}
\usepackage{graphicx}
\begin{document}
\begin{columns}
  \begin{column}
    \begin{verbatim}
    2       0.0035768583
    2.67    0.0040359121
    4       0.0044441355
    6       0.0051378855 
    8       0.0057262546
    10      0.0062415249
    \end{verbatim}
  \end{column}
  \begin{column}
    \begin{figure}[h!]
  \centering
  \includegraphics[scale=.2]{example-image-golden}
  \caption{Gilbert Damping}
\end{figure}
  \end{column}
\end{columns}
\end{document}

结果是这样的:但我希望它们并排。我该如何实现呢? This is what I am ended with

答案1

预期效果并列显示,我是否可以推断verbatim内容也与 相关联figure?如果是这样,则可以使用verbbox

\documentclass[a4paper]{article}
\usepackage{graphicx,verbatimbox}
\begin{document}
\begin{verbbox}[\small]
2       0.0035768583
2.67    0.0040359121
4       0.0044441355
6       0.0051378855 
8       0.0057262546
10      0.0062415249
\end{verbbox}
    \begin{figure}[h!]
  \centering
  \theverbbox\qquad
  \includegraphics[scale=.3]{example-image-golden}
  \caption{Gilbert Damping}
\end{figure}
\end{document}

enter image description here

如果需要垂直居中,可以使用旧$\vcenter{\hbox{...}}$方法

\documentclass[a4paper]{article}
\usepackage{graphicx,verbatimbox,caption,stackengine}
\begin{document}
\begin{verbbox}[\small]
2       0.0035768583
2.67    0.0040359121
4       0.0044441355
6       0.0051378855 
8       0.0057262546
10      0.0062415249
\end{verbbox}
\begin{figure}[h!]
  \centering
  $\vcenter{\hbox{\theverbbox}}$\qquad
  $\vcenter{\hbox{\includegraphics[scale=.2]{example-image-golden}}}$
  \caption{Gilbert Damping}
\end{figure}
\end{document}

enter image description here

另外,还有一种\raisebox方法:

\documentclass[a4paper]{article}
\usepackage{graphicx,verbatimbox,caption,stackengine}
\begin{document}
\begin{verbbox}[\small]
2       0.0035768583
2.67    0.0040359121
4       0.0044441355
6       0.0051378855 
8       0.0057262546
10      0.0062415249
\end{verbbox}
\begin{figure}[h!]
  \centering
  \raisebox{-.5\ht\savedverbbox}{\theverbbox}\qquad
  \raisebox{-.5\height}{\includegraphics[scale=.2]{example-image-golden}}
  \caption{Gilbert Damping}
\end{figure}
\end{document}

以达到相同的输出。

答案2

我建议将两个小页面并排放置,并删除环境figure。要添加不带环境的标题,figure请使用\captionof{figure}{...}caption或提供的环境capt-of

enter image description here

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
  \begin{minipage}{0.45\textwidth}
    \begin{verbatim}
    2       0.0035768583
    2.67    0.0040359121
    4       0.0044441355
    6       0.0051378855 
    8       0.0057262546
    10      0.0062415249
    \end{verbatim}
    \end{minipage}
    \hfill
    \begin{minipage}{0.45\textwidth}
    \includegraphics[width=\textwidth]{example-image-golden}\\
    \captionof{figure}{Gilbert Damping}
  \end{minipage}
\end{document}

答案3

beamer演示文稿中,不需要指定图像是带有数字的“图形”,因为您永远不会引用它。

你也不需要verbatim

\documentclass[a4paper]{beamer}
\usepackage{graphicx}
\begin{document}

\begin{frame}
\begin{columns}
  \column[t]{.4\textwidth}
  \vspace*{0pt}

  \ttfamily
  \begin{tabular}{@{}l@{\qquad}l@{}}
  2     &  0.0035768583 \\
  2.67  &  0.0040359121 \\
  4     &  0.0044441355 \\
  6     &  0.0051378855 \\
  8     &  0.0057262546 \\
  10    &  0.0062415249 \\
  \end{tabular}
  \column[t]{.6\textwidth}
  \vspace*{0pt}

  \centering
  \includegraphics[width=.8\columnwidth]{example-image-golden}

  \bigskip

  Gilbert Damping
\end{columns}
\end{frame}

\end{document}

enter image description here

相关内容