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