LaTeX-设置图像大小

本文详细介绍了如何在LaTeX文档中正确导入和处理图像,包括按比例缩放、指定特定尺寸、使图片与文字宽度一致以及旋转图片的方法,以适应专业文档的需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

LaTeX-设置图像大小

在本文中,将解释如何以最常见的格式包含图像,如何缩小、放大和旋转它们

1.导入图片

\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {./images/} }

\begin{document}
The universe is immense and it seems to be homogeneous, 
in a large scale, everywhere we look at.

\includegraphics{universe}

There's a picture of a galaxy above
\end{document}

LaTeX 本身无法管理图片,因此我们需要使用 graphicx 包。要使用它,我们在导言区包含以下行:

\usepackage{graphicx}

命令 \graphicspath{{./images/}} 告诉 LaTeX 图片保存在主文档目录下名为 images 的文件夹中。

命令 \includegraphics{universe} 实际上是将图片包含进文档中。这里的 universe 是不带扩展名的包含图片的文件名,因此 universe.PNG 变为 universe。图片的文件名不应包含空格或多个点。

注意:允许包含文件扩展名,但最好省略它。如果省略了文件扩展名,将提示 LaTeX 搜索所有支持的格式。

image-20240301164411692

2.更改图像大小并旋转图像

2.1按比例缩放

\begin{document}

Overleaf is a great professional tool to edit online documents, 
share and backup your \LaTeX{} projects. Also offers a 
rather large help documentation.

\includegraphics[scale=1.5]{overleaf-logo}

命令 \includegraphics[scale=1.5]{overleaf-logo} 会将 overleaf-logo 图片包含到文档中,额外的参数 scale=1.5 将会做到确切的效果,即将图片缩放到其实际大小的1.5倍。

2.2将图像缩放到特定的宽度和高度

\begin{document}

Overleaf is a great professional tool to edit online documents, 
share and backup your \LaTeX{} projects. Also offers a 
rather large help documentation.

\includegraphics[width=5cm, height=4cm]{overleaf-logo}

方括号内的参数 [width=3cm, height=4cm] 定义了图片的宽度和高度。可以为这些参数使用不同的单位。如果只传递宽度参数,则高度将被缩放以保持宽高比。

2.3将图片设置为与文字宽度相同

长度单位也可以相对于文档中的某些元素。例如,如果你想让图片与文字宽度相同:

\begin{document}

The universe is immense and it seems to be homogeneous, 
in a large scale, everywhere we look at.

\includegraphics[width=\textwidth]{universe}

除了\textwidth之外,还可以使用任何其他默认的LaTeX长度单位,如:

  • \columnsep:列之间的距离。
  • \columnwidth:列的宽度。
  • \linewidth:当前环境中行的宽度。
  • \paperwidth:页面的宽度。
  • \paperheight:页面的高度。
  • \textwidth:文本的宽度。
  • \textheight:文本的高度。
  • \unitlength:图片环境中的长度单位。

2.4旋转图片

\begin{document}

Overleaf is a great professional tool to edit online, 
share and backup your \LaTeX{} projects. Also offers a 
rather large base of help documentation.

\includegraphics[scale=1.2, angle=45]{overleaf-logo}

参数angle=45将图片逆时针旋转45度。要顺时针旋转图片,请使用负数。

😃😃😃

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值