不同页面上的章节名称和图表

不同页面上的章节名称和图表

\documentclass[11pt,a4paper]{article}
\usepackage[hyperref]{eacl2021}
\usepackage{times}
\usepackage{placeins}
\usepackage{latexsym}
\usepackage{dblfloatfix}
\usepackage{stfloats}
\renewcommand{\UrlFont}{\ttfamily\small}
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{fixltx2e}
%\usepackage[compact]{titlesec}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{xspace}
\usepackage{color}
\usepackage{xcolor}
\usepackage{soul}
\usepackage{cleveref}
\usepackage{afterpage}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{enumerate}
\usepackage[export]{adjustbox}
\usepackage{natbib}
\usepackage{enumitem}
\usepackage{float}
\restylefloat{table}
\usepackage{enumitem}
\crefname{section}{§}{§§}
\Crefname{section}{§}{§§}

\usepackage[compact]{titlesec}
\titlespacing{\section}{0pt}{1ex}{0ex}
\titlespacing{\subsection}{0pt}{0.5ex}{0ex}
\titlespacing{\subsubsection}{0pt}{0.5ex}{0ex}

\section{Examples}
\label{section:examples}
\begin{figure*}[h!]
\centering
\begin{subfigure}{\textwidth}
  \includegraphics[width=\textwidth]{pic.png}
  \caption{ THis is a sample picture}
\end{subfigure}
\begin{subfigure}{\textwidth}
  \includegraphics[width=\textwidth]{pic2.png}
  \caption{This is a sample picture 2}
\end{subfigure}
\caption{Subfigure caption}
\end{figure*}

在此处输入图片描述

在此处输入图片描述

我实际上在不同的页面上同时获得了章节名称和图片。我怎样才能在同一页面上显示章节名称(示例)和图片?

答案1

这会将图形 (minipage) 放入 的可选参数中\twocolumn。请注意,图形 [H] 在那里不起作用。

有趣的是,我收到了一些奇怪的行为\includegraphics

\documentclass[11pt,a4paper]{article}
%\usepackage[hyperref]{eacl2021}% ???
\usepackage{times}
\usepackage{placeins}
\usepackage{latexsym}
\usepackage{dblfloatfix}
%\usepackage{stfloats}% incompatible with dblfloatfix
%\renewcommand{\UrlFont}{\ttfamily\small}
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{fixltx2e}
%\usepackage[compact]{titlesec}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{xspace}
%\usepackage{color}% redundant
\usepackage{xcolor}
\usepackage{soul}
\usepackage{cleveref}
\usepackage{afterpage}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{enumerate}
\usepackage[export]{adjustbox}
\usepackage{natbib}
\usepackage{enumitem}
\usepackage{float}
\restylefloat{table}
\usepackage{enumitem}
\crefname{section}{§}{§§}
\Crefname{section}{§}{§§}

\usepackage[compact]{titlesec}
\titlespacing{\section}{0pt}{1ex}{0ex}
\titlespacing{\subsection}{0pt}{0.5ex}{0ex}
\titlespacing{\subsubsection}{0pt}{0.5ex}{0ex}

\makeatletter
\newcommand{\setcaptype}[1]{\def\@captype{#1}\ignorespaces}
\makeatother

\begin{document}

\twocolumn[\section{Examples}\label{section:examples}

\begin{minipage}{\textwidth}% first line after \section not indented
\setcaptype{figure}
\begin{subfigure}{\textwidth}
  {\includegraphics[width=\linewidth]{example-image-a}}% do not remove braces
  \caption{ THis is a sample picture}
\end{subfigure}\par
\begin{subfigure}{\textwidth}
  {\includegraphics[width=\linewidth]{example-image-b}}% do not remove braces
  \caption{This is a sample picture 2}
\end{subfigure}
\caption{Subfigure caption}
\end{minipage}]

\sloppy
\lipsum[1-3]
\end{document}

相关内容