如何在双列模板中添加图像

如何在双列模板中添加图像

我想知道如何在 LateX 的双列模板中添加图像。我尝试使用 \begin{figure}、\includegraphics{figure} 和 \begin{wrapfigure},但不幸的是文档中没有包含任何图像(图像格式:jpg)。您能告诉我如何在这个模板中添加图像(两列中间,或左右列)吗?非常感谢。

% test.tex
\title{Article Title\cite{LinkReference1}}

\author{Some Author\cite{Author1}}

\newcommand{\abstractText}{\noindent
Abstract goes here.
}

%%%%%%%%%%%%%%%%%
% Configuration %
%%%%%%%%%%%%%%%%%

\documentclass[12pt, a4paper, twocolumn]{article}
\usepackage{xurl}
\usepackage[super,comma,sort&compress]{natbib}
\usepackage{abstract}
\renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small\itshape}
\usepackage{lipsum}

%%%%%%%%%%%%%%
% References %
%%%%%%%%%%%%%%

% If changing the name of the bib file, change \bibliography{test} at the bottom
\begin{filecontents}{test.bib}

@misc{LinkReference1,
  title        = "Link Title",
  author       = "Link Creator(s)",
  howpublished = "\url{https://example.com/}",
}

@misc{Author1,
  author       = "LastName, FirstName",
  howpublished = "\url{mailto:[email protected]}",
}

@article{ArticleReference1,
  author  = "Lastname1, Firstname1 and Lastname2, Firstname2",
  title   = "Article title",
  year    = "Year",
  journal = "Journal name",
  note    = "\url{https://dx.doi.org/...}",
}

\end{filecontents}

% Any configuration that should be done before the end of the preamble:
\usepackage{hyperref}
\hypersetup{colorlinks=true, urlcolor=blue, linkcolor=blue, citecolor=blue}

\begin{document}

%%%%%%%%%%%%
% Abstract %
%%%%%%%%%%%%

\twocolumn[
  \begin{@twocolumnfalse}
    \maketitle
    \begin{abstract}
      \abstractText
      \newline
      \newline
    \end{abstract}
  \end{@twocolumnfalse}
]

%%%%%%%%%%%
% Article %
%%%%%%%%%%%

\section{Section1Title}

This is the first sentence\cite{ArticleReference1}.

\section{Section2Title}

\lipsum[1]

%%%%%%%%%%%%%%
% References %
%%%%%%%%%%%%%%

\nocite{*}
\bibliographystyle{plain}
\bibliography{test}

\end{document}

这就是我试图包含的这个图(链接:https://ibb.co/tZftSFf)

\begin{wrapfigure}{l}{0.7\linewidth}
\includegraphics[width=\linewidth]{figure.jpg}
\end{wrapfigure}

答案1

您必须加载graphicx然后才能\includegraphicsfigure环境中使用:

% test.tex
\title{Article Title\cite{LinkReference1}}

\author{Some Author\cite{Author1}}

\newcommand{\abstractText}{\noindent
Abstract goes here.
}

%%%%%%%%%%%%%%%%%
% Configuration %
%%%%%%%%%%%%%%%%%

\documentclass[12pt, a4paper, twocolumn]{article}
\usepackage{xurl}
\usepackage[super,comma,sort&compress]{natbib}
\usepackage{abstract}
\renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small\itshape}
\usepackage{lipsum}
\usepackage[]{graphicx}

%%%%%%%%%%%%%%
% References %
%%%%%%%%%%%%%%

% If changing the name of the bib file, change \bibliography{test} at the bottom
\begin{filecontents}{test.bib}

@misc{LinkReference1,
  title        = "Link Title",
  author       = "Link Creator(s)",
  howpublished = "\url{https://example.com/}",
}

@misc{Author1,
  author       = "LastName, FirstName",
  howpublished = "\url{mailto:[email protected]}",
}

@article{ArticleReference1,
  author  = "Lastname1, Firstname1 and Lastname2, Firstname2",
  title   = "Article title",
  year    = "Year",
  journal = "Journal name",
  note    = "\url{https://dx.doi.org/...}",
}

\end{filecontents}

% Any configuration that should be done before the end of the preamble:
\usepackage{hyperref}
\hypersetup{colorlinks=true, urlcolor=blue, linkcolor=blue, citecolor=blue}

\begin{document}

%%%%%%%%%%%%
% Abstract %
%%%%%%%%%%%%

\twocolumn[
  \begin{@twocolumnfalse}
    \maketitle
    \begin{abstract}
      \abstractText
      \newline
      \newline
    \end{abstract}
  \end{@twocolumnfalse}
]

%%%%%%%%%%%
% Article %
%%%%%%%%%%%

\section{Section1Title}

This is the first sentence\cite{ArticleReference1}.

\section{Section2Title}

\begin{figure}% >>=
  \centering
  \includegraphics{example-image-duck}%
  \caption
    {%
      A figure.%
      \label{fig:example}%
      }%
\end{figure}% =<<


\lipsum[1]

%%%%%%%%%%%%%%
% References %
%%%%%%%%%%%%%%

\nocite{*}
\bibliographystyle{plain}
\bibliography{test}

\end{document}

相关内容