如何让两个图形彼此相邻并且超出边距?

如何让两个图形彼此相邻并且超出边距?

我一直在 Google 上搜索,试图找到问题的答案,但似乎找不到答案。我有两个想要放在一起的图形。这些图形是 MATLAB 图,并保存为 pdf,因此必须对它们进行剪辑和缩放,以便在我的 latex 文件中获得合适的大小。我尝试使用 minipage 将图形放在一起,这种方法可行,但图形太大,无法容纳在文本宽度内,因此图形的某些部分未显示。有人能帮我解决这个问题吗?

到目前为止,我的乳胶代码如下所示:

\begin{figure}[H]
    \begin{addmargin*}[0cm]{-3cm}
    \begin{minipage}{0.5\textwidth}
    \centering
    \includegraphics[trim={1.4cm 7.5cm 2.0cm 7.5cm},clip, scale = 0.5]{figure1}
    \caption{Caption one.}
    \end{minipage}  

    \begin{minipage}{0.5\textwidth}
    \includegraphics[trim={1.4cm 7.5cm 2.0cm 7.5cm},clip, scale = 0.5]{figure2}
    \caption{Caption two.}
    \end{minipage}
    \end{addmargin*}
\end{figure}

答案1

如果你没有twoside文档,那么你可以忽略该\ifthispageodd

\documentclass[twoside]{scrartcl}
\usepackage{mwe}
\usepackage{showframe}
\newlength\fullwidth
\setlength\fullwidth{\dimexpr\textwidth+\marginparwidth+\marginparsep\relax}
\newenvironment{Figure}
  {\begin{figure}[!htb]%
   \ifthispageodd{}{\hspace*{\dimexpr-\marginparsep-\marginparwidth}}%
   \minipage{\fullwidth}}
  {\endminipage\end{figure}}

\begin{document}
\blindtext\newpage\blindtext

\begin{Figure}
\begin{minipage}[b]{0.49\linewidth}
    \includegraphics[width=\linewidth]{example-image}
    \caption{Caption one.\label{bar}}
\end{minipage}\hfill
\begin{minipage}[b]{0.49\linewidth}
    \includegraphics[width=\linewidth]{example-image-16x10}
    \caption{Caption two.}
\end{minipage}
\end{Figure}

\blindtext
\begin{Figure}
\begin{minipage}{0.49\linewidth}
    \includegraphics[width=\linewidth]{example-image}
    \caption{Caption one.}
\end{minipage}\hfill
\begin{minipage}{0.49\linewidth}
    \includegraphics[width=\linewidth]{example-image}
    \caption{Caption two.\label{foo}}
\end{minipage}
\end{Figure}

As seen in Figure~\ref{bar} on page~\pageref{bar} \ldots

\Blindtext

As seen in Figure~\ref{foo} on page~\pageref{foo} \ldots

\end{document}

在此处输入图片描述

答案2

看样子addmargin是没什么变化\textwidth

\documentclass{scrartcl}
\usepackage{mwe}
\usepackage{showframe}

\begin{document}
\begin{figure}
    \begin{addmargin*}[0cm]{-3cm}%
    \begin{minipage}{0.5\linewidth}
    \centering
    %\includegraphics[trim={1.4cm 7.5cm 2.0cm 7.5cm},clip, scale = 0.5]{figure1}
    \rule{\textwidth}{1in}
    \caption{Caption one.}
    \end{minipage}%
    \begin{minipage}{0.5\linewidth}
    \centering
    %\includegraphics[trim={1.4cm 7.5cm 2.0cm 7.5cm},clip, scale = 0.5]{figure2}
    \rule{\textwidth}{1in}
    \caption{Caption two.}
    \end{minipage}
    \end{addmargin*}
\end{figure}
\end{document}

答案3

针对这种情况,我们设计了软件包changepage。利用其宏adjustwidth(针对单面文档)或adjustwidth*(针对双面文档),您将获得:

在此处输入图片描述

上图的代码:

\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{showframe}
\usepackage{calc}% <--- added
\usepackage[strict]{changepage}% <--- added

\begin{document}
\begin{figure}
\begin{adjustwidth*}{}{-\marginparwidth-\marginparsep}
    \begin{minipage}[b]{0.49\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-a}
    \caption{Caption one.}
    \end{minipage}
\hfill
    \begin{minipage}[b]{0.49\linewidth}
    \includegraphics[width=\linewidth]{example-image-b}
    \caption{Caption two.}
    \end{minipage}
\end{adjustwidth*}
\end{figure}
\end{document}

相关内容