【个人经验】Overleaf 在 two-column 格式中 插入图片 && 插入代码

2023-12-13 22:18:12

一、在 two-column 格式中插入图片的方法

????????1.1??将图片上传至image文件夹

????????1.2? 起始位置处导入包,并将图片上传至image文件夹

% 新增:为导入图片
\usepackage{graphicx} %导入包
\graphicspath{ {image/} }  %image为文件夹名,可以在左侧自己创建文件夹

????????1.3? 目标位置处插入图片

% 插入图片
\begin{figure}[htb]
\centerline{
\includegraphics[width=1.0\linewidth]{image/videoImage.jpg}}
\caption{videoImage} \label{fig:eg}
\end{figure}

二、在 two-column 格式中插入代码的方法

? ? ? ? 2.1?起始位置处导入包

\usepackage[utf8]{inputenc}
\usepackage[UTF8]{ctex}
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{xcolor}

% The following packages can be found on http:\\www.ctan.org
%\usepackage{graphics} % for pdf, bitmapped graphics files
%\usepackage{epsfig} % for postscript graphics files
%\usepackage{mathptmx} % assumes new font selection scheme installed
%\usepackage{mathptmx} % assumes new font selection scheme installed
%\usepackage{amsmath} % assumes amsmath package installed
%\usepackage{amssymb}  % assumes amsmath package installed

% 新增:用于生成对应格式的代码块
\definecolor{mygreen}{rgb}{0,0.6,0}  
\definecolor{mygray}{rgb}{0.5,0.5,0.5}  
\definecolor{mymauve}{rgb}{0.58,0,0.82}  

% 新增:用于生成对应格式的代码块
\lstset{ %  
  backgroundcolor=\color{white},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}  
  basicstyle=\footnotesize,        % the size of the fonts that are used for the code  
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace  
  breaklines=true,                 % sets automatic line breaking  
  captionpos=bl,                    % sets the caption-position to bottom  
  commentstyle=\color{mygreen},    % comment style  
  deletekeywords={...},            % if you want to delete keywords from the given language  
  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code  
  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8  
  frame=single,                    % adds a frame around the code  
  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)  
  keywordstyle=\color{blue},       % keyword style  
  %language=Python,                 % the language of the code  
  morekeywords={*,...},            % if you want to add more keywords to the set  
  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)  
  numbersep=5pt,                   % how far the line-numbers are from the code  
  numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers  
  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))  
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'  
  showstringspaces=false,          % underline spaces within strings only  
  showtabs=false,                  % show tabs within strings adding particular underscores  
  stepnumber=1,                    % the step between two line-numbers. If it's 1, each line will be numbered  
  stringstyle=\color{orange},     % string literal style  
  tabsize=2,                       % sets default tabsize to 2 spaces  
  %title=myPython.py                   % show the filename of files included with \lstinputlisting; also try caption instead of title  
}

? ? ? ? 2.2? 目标位置处插入图片

\begin{lstlisting}[language={python},title={Visualization of Detection Results}]  
# write your code
\end{lstlisting}

文章来源:https://blog.csdn.net/pilgalaxy/article/details/134980430
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。