使用 graphicx 和 Gin 设置图形宽度,仅适用于单个图像(图形的默认宽度是多少,或者清除全局宽度)

使用 graphicx 和 Gin 设置图形宽度,仅适用于单个图像(图形的默认宽度是多少,或者清除全局宽度)

我想在单个图形中控制多个子图形的宽度,然后将它们设置为默认值,MWE:

\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{duckuments}
\usepackage{graphicx}
\newsubfloat{figure}
\begin{document}

\begin{figure}
    \centerfloat
    \subbottom[]{\includegraphics{example-image-duck}}~%
    \subbottom[]{\includegraphics{example-image-duck}}
    \caption{This figure should be of normal width \label{fig}}
\end{figure}


\setkeys{Gin}{width=0.6\textwidth}
\begin{figure}
    \centerfloat
    \subbottom[]{\includegraphics{example-image-duck}}~%
    \subbottom[]{\includegraphics{example-image-duck}}
    \caption{This figure should be wider than in figure \ref{fig}}
\end{figure}
\setkeys{Gin}{} %What should I write here to free the width????

\begin{figure}
    \centerfloat
    \subbottom[]{\includegraphics{example-image-duck}}~%
    \subbottom[]{\includegraphics{example-image-duck}}
    \caption{This figure should be of normal width, like figure \ref{fig}}
\end{figure}

\end{document}

上述代码生成: 在此处输入图片描述

答案1

最简单的方法是将 Gin 设置放在图形内部,然后它将在组结束时重置。但除此之外:默认值是!

\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{duckuments}
\usepackage{graphicx}
\newsubfloat{figure}
\begin{document}


\begin{figure}
    \centerfloat
    \subbottom[]{\includegraphics{example-image-duck}}~%
    \subbottom[]{\includegraphics{example-image-duck}}
    \caption{This figure should be of normal width \label{fig}}
\end{figure}


\setkeys{Gin}{width=0.6\textwidth}
\begin{figure}

    \centerfloat
    \subbottom[]{\includegraphics{example-image-duck}}~%
    \subbottom[]{\includegraphics{example-image-duck}}
    \caption{This figure should be wider than in figure \ref{fig}}
\end{figure}
\setkeys{Gin}{width=!} %What should I write here to free the width????

\begin{figure}
    \centerfloat
    \subbottom[]{\includegraphics{example-image-duck}}~%
    \subbottom[]{\includegraphics{example-image-duck}}
    \caption{This figure should be of normal width, like figure \ref{fig}}
\end{figure}

\end{document}

在此处输入图片描述

相关内容