在一行文字中嵌入小圖像

在一行文字中嵌入小圖像

我無法完美地將圖像嵌入到一行文字中。理想情況下,圖像應縮放至正確的尺寸,以使其適合文字行。據我所知。雖然很近,但圖像太高了。有任何想法嗎?謝謝!

\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} 

在此輸入影像描述

相關內容