边注中的子图

边注中的子图

我的代码,

\documentclass[a4paper,twoside,openright,11pt]{scrbook}
\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[fulladjust]{marginnote}
\usepackage{sidenotes}
\usepackage[svgnames]{xcolor}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{showframe}

\captionsetup{
justification=raggedright,
labelfont={color=Maroon,bf},
font=small}

\begin{document}

\begin{figure}  
  \centering
  \begin{subfigure}[t]{0.45\textwidth}
    \centering
    \includegraphics[width=\textwidth]{IMAGE}
    \caption{One Circuit}\label{fig:1a}
  \end{subfigure}
  \quad
  \begin{subfigure}[t]{0.45\textwidth}
    \centering
    \includegraphics[width=\textwidth]{IMAGE}
    \caption{Two Circuit}\label{fig:1b}
  \end{subfigure}
  \caption{What a nice circuits.}\label{fig:1}
\end{figure}

\marginpar{
\begin{center}
\includegraphics[width=\marginparwidth]{IMAGE}
\captionof{figure}{Picture One in Margin}
\end{center}}

\marginpar{
\begin{center}
\includegraphics[width=\marginparwidth]{IMAGE}
\captionof{figure}{Picture Two in Margin}
\end{center}}
\end{document}

并输出,

在此处输入图片描述

没问题,但是如果可能的话,子图在正文中,相同的子图附在边注中。如果可能的话,再次使用我的序言。

我没有找到重复的另一个问题。我发现它无法完全运行我的代码。有人知道如何修复它吗?

在此处输入图片描述

答案1

借用 egreg 的回答两次使用相同的数字,没有新的数字,这里有一个解决方案。已编辑以更好地匹配格式。

我使用\repeatcaption\repeatsubcaption根据先前的参考重新引用该标签。

\documentclass[a4paper,twoside,openright,11pt]{scrbook}
\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,
  marginparsep=1cm,outer=8cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[fulladjust]{marginnote}
\usepackage{sidenotes}
\usepackage[svgnames]{xcolor}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{showframe}

\captionsetup{
justification=raggedright,
labelfont={color=Maroon,bf},
font=small}

\newcommand{\repeatcaption}[2]{%
  \addtocounter{figure}{-1}%
  \renewcommand{\thefigure}{\ref{#1}}%
  \captionsetup{list=no, labelformat=simple, labelsep=colon}%
  \captionof{figure}{#2}%
}

\newcommand{\repeatsubcaption}[2]{%
  \renewcommand{\thesubfigure}{\subref{#1}}%
  \captionsetup{list=no, labelformat=parens, labelsep=space}%
  \captionof{subfigure}{#2}%
}
\begin{document}
\begin{figure}  
  \centering
  \begin{subfigure}[t]{0.45\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-A}
    \caption{One Circuit}\label{fig:1a}
  \end{subfigure}
  \quad
  \begin{subfigure}[t]{0.45\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-B}
    \caption{Two Circuit}\label{fig:1b}
  \end{subfigure}
  \caption{What a nice circuits.}\label{fig:1}
\end{figure}

\marginpar{
\begin{center}
\includegraphics[width=\marginparwidth]{example-image-A}
\repeatsubcaption{fig:1a}{One Circuit}
\medskip
\includegraphics[width=\marginparwidth]{example-image-B}
\repeatsubcaption{fig:1b}{Two Circuit}
\repeatcaption{fig:1}{What a nice circuits.}
\end{center}}

\end{document}

在此处输入图片描述

答案2

我有这样的解决方案。你想评估一下吗?怎么样?或者有更简单的方法吗?

\documentclass[a4paper,twoside,openright,11pt]{scrbook}
\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage[utf8]{inputenc}
\usepackage[svgnames]{xcolor}

\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{calc}
\usepackage{showframe}

\captionsetup{
justification=raggedright,
labelfont={color=Maroon,bf},
font=small,textfont=it,
indention=0pt,format=plain}

\newcommand{\margintwosubfigures}[5]{
\marginpar{
\includegraphics[width=\marginparwidth]{#1}
\begin{center}\raggedright\small\bfseries\textcolor{Maroon}{(a)} \normalfont\small\itshape {#2}\end{center}
    \includegraphics[width=\marginparwidth]{#3}
    \begin{center}\raggedright\small\bfseries\textcolor{Maroon}{(b)} \normalfont\small\itshape {#4}\end{center}
\captionof{figure}{#5}
}}

\begin{document}

\begin{figure}[h]
\centering
\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}
\caption{I am a figure}
\end{figure}

\margintwosubfigures{example-image-a}{First Subfigure}{example-image-a}{Second Subfigure}{Two Subfigures}

\end{document}

在此处输入图片描述

相关内容