Latex 图像(Figures)

Latex 图像(Figures) 首页 / Latex入门教程 / Latex 图像(Figures)

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

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

在这里,其中代表图形的位置,位于top[t] bottom[b]

插入在figure graphicx 环境中的所有图片将被自动索引并使用连续编号进行标记。它负责文档中图像的定位和编号。您需要包括\includegraphics 命令以插入图像。

图像浮动

浮动是放置在页面一部分中的独立实体,即顶部,底部,中间,左侧,右侧或设计指定的任何位置。浮动始终带有标题和编号,以便可以在文档中的任何位置引用它们。

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

放置说明符为:

无涯教程网

  • h (与源文本位于同一位置)
  • b (底部), t (顶部)
  • p (位于特殊页面上,仅用于浮动)
  • (覆盖)
  • H 要实现此浮动说明符,必须使用软件包\usepackage {float}

图像标题

下面给出以下示例:

\documentclass[12pt]{article}
\usepackage{graphicx,xcolor} %引入graphicx和xcolor包
\begin{document}
    \title{Welcome LearnFK Latex Images Tutorials} 
    \maketitle
    
    \pagecolor{lightgray}
    
    \begin{figure}[h!]  % h:与源文本位于同一位置 !:覆盖
        \caption{ This is the logo of our website}
        \begin{center}
            \graphicspath{ {image/} } % 这里指定图片目录
            \includegraphics[width=0.5\textwidth]{logo}
        \end{center}
    \end{figure}
    
\end{document}

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

Latex Figure

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

\documentclass[12pt]{article}
\usepackage{graphicx,xcolor,float} %引入graphicx和xcolor包和float包
\begin{document}
    \title{Welcome LearnFK Latex Images Tutorials} 
    \maketitle
    
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....
    
    \begin{figure}[H]  % H:浮动说明符
        \centering
            \graphicspath{ {image/} } % 这里指定图片目录
            \includegraphics[width=0.5\textwidth]{logo}  % 指定宽度
            \caption{ This is the picture of learnfk logo}
    \end{figure}
    
\end{document}

输出:

Latex Figure

下面是带有一个和两个标题的两张图:

带有一个标题,两张图像示例

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

\documentclass[12pt]{article}
\usepackage{graphicx,xcolor,float} %引入graphicx和xcolor包和float包
\begin{document}
    \title{Welcome LearnFK Latex Images Tutorials} 
    \maketitle
    
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....
    
    \begin{figure}[H]  % H:浮动说明符
        \centering
            \graphicspath{ {image/} } % 这里指定图片目录
            \includegraphics[scale=0.2]{logo}  % 指定宽度
            \hspace{3in} % 添加一些水平间距
            \includegraphics[scale=0.2]{logo} 
            \caption{ \color{blue}{This is the picture of learnfk logo}} 
            \label{fig: Learnfk Logo}
    \end{figure}
    
\end{document}

输出:

Latex Figure

两个标题,两张图像示例

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

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

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

\documentclass[12pt]{article}
\usepackage{graphicx,xcolor,float} %引入graphicx和xcolor包和float包
\begin{document}
    \title{Welcome LearnFK Latex Figures Tutorials} 
    \maketitle
    
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....
    
    \begin{minipage}[c]{0.5\textwidth}
        \begin{figure}[H]  % H:浮动说明符
            \centering
                \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
                \includegraphics[scale=0.2]{logo}  % 指定宽度
                \caption{Example LearnFk Logo1}
                \label{fig:Login1}
       \end{figure}    
    \end{minipage}
    \begin{minipage}[c]{0.5\textwidth}
        \begin{figure}[H]  % H:浮动说明符
            \centering
                \graphicspath{ {image/} } % 这里指定图片目录
                \includegraphics[scale=0.2]{logo} 
                \caption{ \color{blue}{Example LearnFk Logo2}} 
                \label{fig:Logo2}
        \end{figure}
    \end{minipage}
    
\end{document}

输出:

Latex Figure

图片标签

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

\documentclass[12pt]{article}
\usepackage{graphicx,xcolor,refstyle,caption} %引入graphicx和xcolor包和refstyle包
\begin{document}
  
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....
    
    \large Hello Would 
    \begin{figure}[t]  % t:表示顶部
        \centering
            \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
            \includegraphics[scale=0.2]{logo}  % 指定宽度
            \caption{Example LearnFk Logo}
            \label{fig:Login}
   \end{figure}    
   as shown in \figref{Login}
\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} 
    \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[12pt]{article}
\usepackage{graphicx,xcolor,refstyle,caption} %引入graphicx和xcolor包和refstyle包
\begin{document}
    \title{Example LearnFK Latex Figures } 
    \author{ My name is LearnFk} 
    \date{\today }
    \maketitle
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....

    \begin{figure}[t]
        \centering
            \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
            \includegraphics[scale=0.2]{logo}  % 指定宽度
            \caption{Example LearnFk Logo}
            \label{fig:Login}
    \end{figure}  
    
    \begin{figure}[t]
        \centering
            \reflectbox{%    %这里是\reflectbox{% } 格式
                \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
                \includegraphics[scale=0.2]{logo} % 指定宽度
            }  
                \caption{Example LearnFk Logo2}
                \label{fig:Login}
    \end{figure}  
    
\end{document}

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

输出:

Latex Figure

子图

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

代码或程序如下:

\documentclass[a5paper,12pt]{article}
\usepackage{graphicx,xcolor,subcaption} %引入graphicx和xcolor包和subcaption包
\begin{document}
    \title{Example LearnFK Latex Figures } 
    \author{ My name is LearnFk} 
    \date{\today }
    \maketitle
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....

    \begin{figure}[h]
        \centering 
            \begin{subfigure}[b]{0.4\linewidth}  %在这里,b 表示底部
                \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
                \includegraphics[width=\linewidth]{logo}  % 指定宽度
                \caption{Example LearnFk Logo1}
            \end{subfigure}
            \begin{subfigure}[b]{0.4\linewidth}  %在这里,b 表示底部
                \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
                \includegraphics[width=\linewidth]{logo}  % 指定宽度
                \caption{Example LearnFk Logo2}
            \end{subfigure}
            
            \caption{ The two log design}
            \label{fig:logo}
    \end{figure}  
    
   
    
\end{document}

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

输出:

Latex Figure

图表

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

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

\documentclass[a5paper,12pt]{article}
\usepackage{graphicx,xcolor} %引入包
\begin{document}
    \title{Example LearnFK Latex Figures } 
    \author{ My name is LearnFk} 
    \date{\today }
    \maketitle
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....
    
    \begin{table}[]
        \centering
        \begin{tabular}{cc}
            Hi LearnFK &  Hi Google \\
            \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
            \includegraphics[scale=0.3]{logo}  % 指定宽度 & 
            &
            \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
            \includegraphics[scale=0.3]{logo}  % 指定宽度 & 
        \end{tabular}
        \caption{Caption}
        \label{tab:my_label}
    \end{table}
\end{document}

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

输出:

Latex Figure

2。第二个示例的代码如下:

\documentclass[a5paper,12pt]{article}
\usepackage{graphicx,xcolor} %引入包
\begin{document}
    \title{Example LearnFK Latex Figures } 
    \date{\today }
    \maketitle
    \pagecolor{lightgray} %设置背景色,因为我logo是白色的....
    
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c |c |} \hline Name & Website \\\hline
            Google &  
            \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
            \includegraphics[scale=0.3]{logo} \\\hline  % 指定宽度 & 
            Learnfk & 
            \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
            \includegraphics[scale=0.3]{logo}  % 指定宽度 & 
            \\\hline
        \end{tabular}
        \caption{Caption}
        \label{tab:my_label}
    \end{table}
\end{document}

输出:

Latex Figure

列表和种类

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

\documentclass[12pt]{article}
\usepackage{graphicx,xcolor}

\newcommand{\species}[1]{\textit{#1} sp.} % \textit{#1} 用于以斜体显示名称

\pagecolor{lightgray} %设置背景色,因为我logo是白色的....
\begin{document}
    \listoffigures
    \section{Introduction}
    
    \begin{figure}[h]
        \centering
         \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
          \includegraphics[width=\linewidth]{logo}  % 指定宽度
        \caption[Close up of cat species \species{lynx}]
        	{Close up of \species{lynx}, Learnfk tutorials provide programmers with basic introductory tutorials. This site includes Javascript, MYSQL, PHP, Python, Java, HTML5, Flutter, Redis, Nativescript, VueJs, Golang, big data, artificial intelligence and other basic programming tutorials.}  % \species{lynx}命令用于以格式显示名称
    \end{figure}
\end{document}  

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

输出:

Latex Figure

文字换行

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

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

\usepackage{wrapfig}.

它可以访问命令,即

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

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

\documentclass[12pt]{article}
\usepackage{graphicx,xcolor,wrapfig}

\pagecolor{lightgray} %设置背景色,因为我logo是白色的....

\begin{document}
    \begin{wrapfigure}{i}{100mm}
        \begin{center}
            Learnfk tutorials provide programmers with basic introductory tutorials. This site includes Javascript, MYSQL, PHP, Python, Java, HTML5, Flutter, Redis, Nativescript, VueJs, Golang, big data, artificial intelligence and other basic programming tutorials
            \graphicspath{ {image/} } % 这里指定图片目录,如果不指定,则从同文件目录找
            \includegraphics[scale=0.3]{logo}  % 指定宽度
            \caption{ The LearnFK}
            Learnfk tutorials provide programmers with basic introductory tutorials. This site includes Javascript, MYSQL, PHP, Python, Java, HTML5, Flutter, Redis, Nativescript, VueJs, Golang, big data, artificial intelligence and other basic programming tutorials\includegraphics[scale=0.2]{mingyan}  % 指定宽度
             \caption{ The LearnFK Again}
        \end{center}
    \end{wrapfigure}
\end{document}  

输出:

Latex Figure

下表列出了总共使用的八个属性:

位置名称说明
R,r文本的右侧
I,i内边缘
O,o外边缘
L,l文本的左侧

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

零基础学Python -〔尹会生〕

白话法律42讲 -〔周甲徳〕

Linux内核技术实战课 -〔邵亚方〕

程序员的个人财富课 -〔王喆〕

PyTorch深度学习实战 -〔方远〕

超级访谈:对话张雪峰 -〔张雪峰〕

人人都用得上的数字化思维课 -〔付晓岩〕

商业思维案例笔记 -〔曹雄峰〕

结构写作力 -〔李忠秋〕

好记忆不如烂笔头。留下您的足迹吧 :)