个性化阅读
专注于IT技术分析

Latex图figure

本文概述

Latex中的图形和图形是使用图形环境创建的, 表示为:

\begin{figure}[where]
......
\end{figure}

在此, 其中代表图形的位置在顶部[t]或底部[b]。

图中插入的所有图片和graphicx环境将被自动索引并用连续编号标记。它负责处理文档中图像的位置和编号。你需要包括\ includegraphics命令以插入图像。

Latex采用一些原则来安排文本, 通常称为浮点数。

浮点数

浮点数可以解决该问题, 以适合同一页或当前页上不适合的文本。浮点数是放置在页面一部分中的独立实体, 即页面的顶部, 底部, 中间, 左侧, 右侧或设计指定的任何位置。浮点数始终带有标题和编号, 以便可以在文档中的任何位置引用它们。

浮动是使用图形环境创建的, 如下所示:

\begin{figure}{placement specifier}
..........
\end{figure}

放置说明符为:

  • h(与源文本位于同一位置)
  • b(底部), t(顶部)
  • p(放在特殊页面上, 仅用于浮点数)
  • ! (覆盖)
  • H(它将浮子放置在精确的位置)。必须使用\ usepackage {float}软件包才能实现此float说明符。

字幕数字

下面给出以下示例:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{figure}[h!]
\caption{The picture of the lion}
\begin{center}
\includegraphics[width=0.2\textwidth]{lion}
\end{center}
\end{figure}

\end{document}

在这里, 我们指定了center命令以在中心显示图像。 \ textwidth命令用于确定图片的宽度。

输出:

Latex图figure

让我们考虑另一个使用float包的字幕示例。

\documentclass{article}
\usepackage{float}
\usepackage{graphicx}
\begin{document}

\begin{figure}[H]
\centering
\includegraphics[scale=0.3]{star1}
\caption{This is the picture of stars}
\end{figure}

\end{document}

输出:

Latex图figure

下面是带有一个和两个标题的两个数字:

带一个标题的两个数字

下面给出了两个带有一个标题的数字的代码:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{float}
\begin{document}

\begin{figure}[H]
\centering
\includegraphics[height=1.1in]{traffic}%
\hspace{1.3in}% to add some horizontal spacing
\includegraphics[height=1.1in]{traffic1}%
\caption{Example \LaTeX\ traffic pictures with One Caption} 
\label{fig:traffic logo}
\end{figure}

\end{document}

输出:

Latex图figure

带有两个标题的两个数字

在此示例中, 我们使用了minipage命令。该命令写为\ begin {minipage} [c] {0.5 \ textwidth}。你可以根据需要确定宽度。

minipage命令用于使事物彼此相邻, 否则将很难实现。它用于在现有页面内构建其他页面。例如, 两张图片并排放置。

下面给出了带有两个标题的两个图形的代码:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{float}
\begin{document}

\begin{minipage}[c]{0.5\textwidth}
\begin{figure}[H]
\centering
\includegraphics[height=1.2in]{traffic}
\caption{Example traffic logo} 
\label{fig:traffic1}
\end{figure}
\end{minipage}
\begin{minipage}[c]{0.5\textwidth}
\begin{figure}[H]
\centering
\includegraphics[height=1.2in]{traffic1}
\caption{Example traffic logo} 
\label{fig:traffic2}
\end{figure}
\end{minipage}

\end{document}

输出:

Latex图figure

图片标签和参考

对于标签和参考, 你需要包括refstyle包。该命令写为\ usepackage {refstyle}。让我们通过一个例子来理解它。代码如下:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{refstyle}
\usepackage{caption}

\begin{document}
\large A variety of flowers  
\begin{figure}[t]
\includegraphics[width=0.5\textwidth]{flower}
\caption{A picture of bundle of flowers}
\label{fig:flower}
\end{figure}
as shown in \figref{flower}
 
\end{document}

\ figref命令用于在文档中进一步引用该图片。裁判将自动编号。

输出:

Latex图figure

专柜

在Latex中, 表格和图形具有独立的计数器。你会注意到以下示例中给出的代码和输出。

\documentclass[a5paper, 12pt]{article}
\usepackage{graphicx}
\begin{document}

\begin{figure}
 \caption{A picture of a lion.}
 \centering
 \includegraphics[width=0.2\textwidth]{lion}
 \end{figure}

 \begin{figure}
 \centering
  \includegraphics[width=0.3\textwidth]{star1} % the picture of lion and star1 are saved in the folder where the Latex files are present
 \caption{A picture of stars}
\end{figure}

\begin{table}
\centering
    \begin{tabular}{| l| c |r |}
    \hline
    a & b & c \\
    d & e & f \\
    \hline
    \end{tabular}
  \caption{A simple table}
\end{table}

\end{document}

输出:

Latex图figure

反射图片

对于同一张图片的反射图像, 请使用reflectbox命令。该命令写为\ reflectbox {%\ includegraphics {…}}。下面的示例给出了代码和输出:

\documentclass[a5paper, 12pt]{article}
\usepackage{graphicx}
\begin{document}

\begin{figure}
 \caption{A picture of a bird.}
 \centering
 \includegraphics[width=0.5\textwidth]{bird}
 \end{figure}
 
 \begin{figure}
 \centering
 \reflectbox{%
  \includegraphics[width=0.5\textwidth]{bird}}
 \caption{A reflected picture of same bird}
\end{figure}

\end{document}

你会注意到原始图片和反射图片之间的差异。

输出:

Latex图figure

Latex中的子图

有时需要添加多于一两张图片。环境子图用于显示多个图像。你需要添加各种子图环境进行配置。

代码或程序如下:

\documentclass[a5paper, 12pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}

\begin{figure}[h]
 \centering
 \begin{subfigure}[b]{0.4\linewidth} % here, b means bottom
 \includegraphics[width=\linewidth]{coffee}
 \caption{Coffee}
 \end{subfigure}
 \begin{subfigure}[b]{0.4\linewidth}
 \includegraphics[width=\linewidth]{coffee1} % you can specify any picture
 \caption{Another coffee}
 \end{subfigure}
 \caption{The two types of coffee design}
 \label{fig:coffee}
\end{figure}

\end{document}

你可以在输出中注意到彼此相邻的两张图片。

输出:

Latex图figure

图表

下面给出了以表格格式包含数字的两个示例:

1.第一个示例的代码如下:

\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor, soul} % this package is added because of the background-color

\begin{document}
\begin{table}
\begin{tabular}{cc}
\pagecolor{pink}
 CD (Compact Disk) & Hard Disk Drive \\
\includegraphics[height=1.4in]{CD} &
\includegraphics[height=1.4in]{HDD} \\
\end{tabular}
\end{table}

\end{document}

在这里, 我们使用了背景色来增强文档。

输出:

Latex图figure

2.下面是第二个示例的代码:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\begin{table}
\begin{tabular}{|c |c|} \hline
 Time & Flower \\
1s & \includegraphics[height=0.6in]{flower1} \\ \hline % the picture was saved with the flower1 name
2s & \includegraphics[height=0.8in]{flower1} \\ \hline
3s & \includegraphics[height=1.0in]{flower1} \\ \hline
4s & \includegraphics[height=1.2in]{flower1} \\ \hline
\end{tabular}
\end{table}

\end{document}

输出:

Latex图figure

清单和种类

使用listoffigures命令显示该列表。使用此命令将自动为页码和列表名称编号。 \ newcommand物种的形成是为了在文档中突出显示物种名称。示例如下:

\documentclass[12pt, ]{article}
\usepackage{graphicx}
\newcommand{\species}[1]{\textit{#1} sp.} % \textit{#1} is used to display the name of species in italics
\begin{document}

\listoffigures
\section{Introduction}

\begin{figure}[h]
\centering
\includegraphics[width=2.5in]{lynx}
\caption[Close up of cat species \species{lynx}]
	{Close up of \species{lynx}, which is part of the cat family. It is the species within the medium size wild cat live in Europe and Africa.}  % \species{lynx} command is used to display the species word in the format declared above, i.e., italics
\end{figure}

\end{document}

你可以使用任何文本格式来显示物种名称。

输出:

Latex图figure

文字换行

作者更喜欢将文字环绕在图片周围, 以免中断流程。包装数字和文字需要大量调整。它包括软件包和特殊命令。

使用的包是wrapfig包。该命令写为:

\usepackage{wrapfig}.

它可以访问命令, 即

\begin{wrapfigure}[lineheight]{position}[overhang]{width}

让我们通过一个例子来理解它。代码如下:

\documentclass{article}
\usepackage{graphicx}
\usepackage{wrapfig}

\begin{document}
\begin{wrapfigure}{i}{100mm}
\begin{center}
The Sun is the star that is present at the center of the Solar System. It is considered the most important source of energy for life on Earth. The diameter of the Sun is 109 times that of the Earth, while the mass of Sun is about 330, 000 times the mass of the Earth. The Sun every second converts 4 million tones of matter into energy.

\includegraphics[scale=0.1]{sun}
\caption{The Sun}
The Sun consists of the hydrogen and helium with smaller quantities of oxygen, carbon, neon, iron, and some heavier elements. The contribution of hydrogen is approx 73 percent, and helium is about 25 percent.
\includegraphics[scale=0.3]{sun1}

\caption{The Sun cartoon}
\end{center}
\end{wrapfigure}

\end{document}

输出:

Latex图figure

下表列出了总共使用的八个位置:

职位名称 说明
, 文字右侧
我, 我 内缘
喔喔 外缘
文字左侧

赞(0)
未经允许不得转载:srcmini » Latex图figure

相关推荐

评论 抢沙发

评论前必须登录!