在一行文本中嵌入小图像

在一行文本中嵌入小图像

我无法完美地将图像嵌入文本行中。理想情况下,图像应缩放到正确的大小,以便适合文本行。这是我所能做到的。虽然很接近,但图像太高了。有什么想法吗?谢谢!

\documentclass[preprint2]{aastex}

\usepackage{graphicx}

\newcommand*{\img}[1]{%
    \raisebox{-.02\baselineskip}{%
        \includegraphics[
        height=\baselineskip,
        width=\baselineskip,
        keepaspectratio,
        ]{#1}%
    }%
}

\begin{document}

\begin{enumerate}
\item When ready, click `record \img{Record.png}'.  There will be a three second period before the actual data collection begins.
\end{enumerate}

\end{document}

下面是我得到的图片:

示例图像

答案1

像这样?

老虎综合

\documentclass{article}
\usepackage{graphicx,calc}
\newlength\myheight
\newlength\mydepth
\settototalheight\myheight{Xygp}
\settodepth\mydepth{Xygp}
\setlength\fboxsep{0pt}
\begin{document}
  This is some arbitrary \raisebox{-\mydepth}{\fbox{\includegraphics[height=\myheight]{tiger}}} line of uninteresting text.
\end{document}

如上所述,这不会适应文档中的字体大小变化。但是,您可以定义一个新\inlinegraphics{}命令来执行此操作:

\documentclass{article}
\usepackage{graphicx,calc}
\newlength\myheight
\newlength\mydepth
\settototalheight\myheight{Xygp}
\settodepth\mydepth{Xygp}
\setlength\fboxsep{0pt}
\newcommand*\inlinegraphics[1]{%
  \settototalheight\myheight{Xygp}%
  \settodepth\mydepth{Xygp}%
  \raisebox{-\mydepth}{\includegraphics[height=\myheight]{#1}}%
}
\begin{document}
  This is some arbitrary \raisebox{-\mydepth}{\fbox{\includegraphics[height=\myheight]{tiger}}} line of uninteresting text.

  This should adapt \inlinegraphics{example-image-a}.

  \Huge Will this adapt \inlinegraphics{example-image-b} nicely?

  \tiny That is yet to be \inlinegraphics{example-image-a} seen.
\end{document}

适应性老虎

答案2

只需降低0.3\baselineskip

\documentclass{article}%[preprint2]{aastex}

\usepackage{graphicx}

\newcommand*{\img}[1]{%
    \raisebox{-.3\baselineskip}{%
        \includegraphics[
        height=\baselineskip,
        width=\baselineskip,
        keepaspectratio,
        ]{#1}%
    }%
}

\begin{document}

\begin{enumerate}
\item When ready, click `record \img{Vinyl.png}'. There will be a three second period before the actual data collection begins.
\end{enumerate}

\end{document} 

在此处输入图片描述

相关内容