如何在 LaTeX 中对图像进行文字包装。
例如:在技术文档中,作者姓名将与其图像一起以文字形式包裹。
答案1
只是为了在这里添加另一个答案,以防其他人有这个问题 - 你可以用wrapfig包很好地将文本环绕在图形周围。这是一个简短的示例,显示了带有标题的左对齐和右对齐图像,文本环绕在图像周围。
这个例子也是可在 Overleaf 上查看如果您想查看代码旁边的 pdf 输出。
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{wrapfig}
\title{Package Example: wrapfig}
\author{writeLaTeX}
\begin{document}
\maketitle
\begin{wrapfigure}{R}{0.3\textwidth}
\centering
\includegraphics[width=0.25\textwidth]{frog.jpg}
\caption{\label{fig:frog1}This is a figure caption.}
\end{wrapfigure}
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae,
felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac
turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et
lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet
tortor gravida placerat. Integer sapien est, iaculis in, pretium quis,
viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus.
Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur
auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu,
accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci
dignissim rutrum.
\begin{wrapfigure}{L}{0.3\textwidth}
\centering
\includegraphics[width=0.25\textwidth]{frog.jpg}
\caption{\label{fig:frog2}This is a figure caption.}
\end{wrapfigure}
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi
auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae,
ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat
ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl
hendrerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla.
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis.
Pellentesque cursus luctus mauris.
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at,
tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy
pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa ac
quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo.
Maecenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a,
ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed
lacinia nulla vitae enim. Pellentesque tincidunt purus vel magna. Integer non
enim. Praesent euismod nunc eu purus. Donec bibendum quam in tellus. Nullam
cursus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum
pellentesque felis eu massa.
\end{document}
外观:
编辑:想添加一条注释,说明我是 Overleaf(以前称为 WriteLaTeX)的开发人员之一,欢迎提供任何反馈!谢谢 :-)
答案2
由于作者姓名通常不太长,无法用作文本环绕图像,我想您想将图像放在文本模式中?
可以使用\includegraphics
不依赖于环境figure
或类似情况的方法来做到这一点。此外,缩放图像的方法有很多,可以旋转图像并以不同的方式定位。以下示例缩放适合线内的图像(\baselineskip
. 30% 为深度,70% 为图像高度,取自的值\strut
)。
示例文件:
\documentclass{article}
\usepackage{graphicx}
\newcommand*{\authorimg}[1]{%
\raisebox{-.3\baselineskip}{%
\includegraphics[
height=\baselineskip,
width=\baselineskip,
keepaspectratio,
]{#1}%
}%
}
\begin{document}
\begin{itemize}
\item[\authorimg{PeterM_Foxhead.png}] Author of Firefox
\item[\authorimg{Andy_ant.png}] Author of Apache Ant
\end{itemize}
\end{document}
图片取自开放剪贴画: