0

I would like to know how to add an image in a two-columns template in LateX. I have tried to use \begin{figure}, \includegraphics{figure}, and \begin{wrapfigure}, but unfortunately no image was included in the document (image's format: jpg). Could you please tell me how add an image (center between the two columns, or on the right/left columns) in this template? Many thanks.

% 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}

This is what I have tried to include this figure (link: https://ibb.co/tZftSFf):

\begin{wrapfigure}{l}{0.7\linewidth}
\includegraphics[width=\linewidth]{figure.jpg}
\end{wrapfigure}
3
  • Do I understand correctly that you want text wrapped around your figure? I'm afraid a cutout in both columns isn't possible, but using wrapfig you should be able to create a figure with text wrapping around it inside one of the two columns. Can you please show us what you've tried to include a figure? You can use the dummy image example-image-duck which should be contained in most LaTeX installations.
    – Skillmon
    Commented Jan 30, 2020 at 23:05
  • I updated the question. It is not clear to me what you mean with 'use the dummy image'. Actually, I would prefer to not wrap text around the figure. I would like just to add a figure in that template, in one of the two columns.
    – Math
    Commented Jan 30, 2020 at 23:51
  • If you don't want the text to be wrapped around the figure then don't use wrapfig, that's its only purpose. With example-image-duck I meant that you should use that instead of figure.jpg, because we don't have that file on our pc.
    – Skillmon
    Commented Jan 31, 2020 at 0:15

1 Answer 1

0

You have to load graphicx and then you can use \includegraphics inside the figure environment:

% 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}
2
  • Thank you for your help! I had forgotten to include the package..
    – Math
    Commented Jan 31, 2020 at 0:17
  • @math.world it could happen to anybody. Note that graphicx isn't necessary for the figure environment, but for \includegraphics.
    – Skillmon
    Commented Jan 31, 2020 at 0:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .