子圖使用 subfloatrow、overpic、tikz 新增行來註解匯入的影像/圖

子圖使用 subfloatrow、overpic、tikz 新增行來註解匯入的影像/圖

subfloatrow我認真搜尋了、overpic和 添加箭頭以使用 來註釋導入圖像的組合tikz,但找不到。這些類型的圖像通常出現在生物學領域,它們可以用於蛋白質印跡或凝膠電泳等......想法總是相同的;是獲取帶有文字註釋的多個圖像(快遞在這裡很合適),並且通常使用優雅而簡單的箭頭來指向圖像中特定的波段或感興趣的點。

推薦,除非您報告更好的!

  • overpic:針對此類文字註釋的一個非常好的解決方案
  • floatrow:在處理子浮動(圖形和表格)以及子標題和許多其他功能方面,AFIK 是最好的
  • mdframed:一個功能豐富的控制框架包
  • tikz:一個用於繪製箭頭和圖形的無評論包(tikz 粉絲!)

請在回答中避免這些

  • subfig: 過時的
  • subfigure:支持,不維護
  • subcaptionfloatrow:很好,但是它的手冊會引導您找到更好的一個,即用於更複雜的子浮點 的 subfloatrow 環境

現在需要什麼?

  • 在最小工作範例(MWE)中至少向其中一個子圖添加箭頭,水平箭頭,從左到右以及相反方向。請提供相對的測量以微調箭頭定位。歡迎不同的、優雅的 tikz 箭頭,我是否忘記在這裡提到優雅?

  • 控制這些影像之間的空間(在本例中增加它)

  • 參考主圖標題中的子圖

MWE代碼

\documentclass[12pt]{scrartcl} % KOMA script
\usepackage{courier} % courier font for text annotation
\usepackage[labelsep=period]{caption} % for appearance of captions not placings
\usepackage{subcaption} % incompatible with subfig, or subfigure (obsolete)
\usepackage[demo]{graphicx} % for graphcis, demo to provide image placeholders
\usepackage{xcolor} % colors
\usepackage[framemethod=tikz]{mdframed} % for frames, load xcolor before!
\usepackage{tikz} % drawing arrows and graphics
\usetikzlibrary{arrows} % arrow library for tikz
\usepackage{floatrow} % has the subfloatrow environment for subfloats   
\usepackage[percent]{overpic} % for text annotation over imported pictures
\begin{document}
\begin{figure}
\begin{mdframed}[align=center,linecolor=black,fontcolor=black,backgroundcolor=white,userdefinedwidth=0.9\textwidth,roundcorner=5pt,skipabove=10pt,skipbelow=10pt,leftmargin=0pt,innertopmargin=100pt,innerbottommargin=0pt, innerleftmargin=50pt,innerrightmargin=20pt, innerlinewidth=0pt, middlelinewidth=0pt,outerlinewidth=1pt] % change the innertopmargin for labels
\floatsetup[subfigure]{captionskip=10pt} 
\ffigbox { %
  \begin{subfloatrow}[3]% number of subfigures are 3, 2 by default
    \ffigbox{
    \begin{overpic}[grid,tics=15]{image1} % remove the grid, tics argument later on
    \put (-30,0) {$ \beta $-actin}
    \put(1,67){\rotatebox{90}{\texttt{Lane1: geneA}}}
    \put(15,67){\rotatebox{90}{\texttt{Lane2: geneB}}}
    \put(30,67){\rotatebox{90}{\texttt{Lane3: geneC}}}
    \end{overpic}
       }{\subcaption{subcap1}}
    \ffigbox{\includegraphics{image2}}{\subcaption{subcap2}} % you can do the same as image 1 with overpic
    \ffigbox{\includegraphics{image3}}{\subcaption{subcap3}} % you can do the same as image 1 with overpic
  \end{subfloatrow}  
}{\caption{A Minimal Working Example}}
\end{mdframed}
\end{figure}  

這使

微量元素

答案1

基本思想是使用 TikZ 將圖像放置在帶有名稱的節點內;這將使您能夠控制位置並允許放置箭頭。

\label只需使用,機制即可滿足交叉引用的要求\ref

一些解釋

overpic我決定根本不使用。標籤的網格和放置完全可以透過TikZ完成;在下面的例子中我使用了卡拉姆迪爾'沙傑克的回答使用 TikZ 在圖像上繪圖並定義了一個\mygrid在每個影像上放置標記網格的命令;的強制參數\mygrid是用來保存映像的節點的名稱:

\documentclass[12pt]{scrartcl}
\usepackage{courier}
\usepackage[labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{floatrow}

\newcommand\mygrid[1]{%
  \begin{scope}[x={(#1.south east)},y={(#1.north west)}]
  \draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
  \foreach \x in {0,1,...,10} { \node [anchor=north,font=\tiny] at (\x/10,0) {\x}; }
  \foreach \y in {0,1,...,10} { \node [anchor=east,font=\tiny] at (0,\y/10) {\y}; }
  \end{scope}%
}

\begin{document}

\begin{figure}
\begin{mdframed}[
  align=center,
  linecolor=black,
  fontcolor=black,
  backgroundcolor=white,
  %userdefinedwidth=0.9\textwidth,
  roundcorner=5pt,
  skipabove=10pt,
  skipbelow=10pt,
  leftmargin=0pt,
  innertopmargin=100pt,
  innerbottommargin=0pt, 
  innerlinewidth=0pt,
  middlelinewidth=0pt,
  outerlinewidth=1pt
]
\floatsetup[subfigure]{captionskip=10pt}
\ffigbox{%
\begin{subfloatrow}[3]
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (image1) 
    {\includegraphics[width=3.8cm]{ctanlion}};
  \mygrid{image1}
  \end{tikzpicture}
  }%
  {\subcaption{subcap1}\label{sfig:a}}%
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
    \node[anchor=south west,inner sep=0] (image2)  
      {\includegraphics[width=3.8cm]{ctanlion}};
  \mygrid{image2}
  \end{tikzpicture}
  }%
  {\subcaption{subcap2}\label{sfig:b}}
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (image3) 
    {\includegraphics[width=3.8cm,height=2cm]{ctanlion}};
  \mygrid{image3}
  \end{tikzpicture}
  }%
  {\subcaption{subcap3}\label{sfig:c}}
\end{subfloatrow}  
}{\caption{A Minimal Working Example with three subfigures:~\ref{sfig:a}, \ref{sfig:b} and~\ref{sfig:c}}}
\end{mdframed}
\end{figure}

\end{document}

這會產生:

在此輸入影像描述

現在,在網格的幫助下,我們可以繪製一些箭頭並放置標籤:

\documentclass[12pt]{scrartcl}
\usepackage{courier}
\usepackage[labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{floatrow}

\newcommand\mygrid[1]{%
  \begin{scope}[x={(#1.south east)},y={(#1.north west)}]
  \draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
  \foreach \x in {0,1,...,10} { \node [anchor=north,font=\tiny] at (\x/10,0) {\x}; }
  \foreach \y in {0,1,...,10} { \node [anchor=east,font=\tiny] at (0,\y/10) {\y}; }
  \end{scope}%
}

\begin{document}

\begin{figure}
\begin{mdframed}[
  align=center,
  linecolor=black,
  fontcolor=black,
  backgroundcolor=white,
  %userdefinedwidth=0.9\textwidth,
  roundcorner=5pt,
  skipabove=10pt,
  skipbelow=10pt,
  leftmargin=0pt,
  innertopmargin=100pt,
  innerbottommargin=0pt, 
  innerlinewidth=0pt,
  middlelinewidth=0pt,
  outerlinewidth=1pt
]
\floatsetup[subfigure]{captionskip=10pt}
\ffigbox{%
\begin{subfloatrow}[3]
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (image1) 
    {\includegraphics[width=3.8cm]{ctanlion}};
  \mygrid{image1}
  \end{tikzpicture}
  }%
  {\subcaption{subcap1}\label{sfig:a}}%
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
    \node[anchor=south west,inner sep=0] (image2)  
      {\includegraphics[width=3.8cm]{ctanlion}};
  \mygrid{image2}
  \end{tikzpicture}
  }%
  {\subcaption{subcap2}\label{sfig:b}}
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (image3) 
    {\includegraphics[width=3.8cm,height=2cm]{ctanlion}};
  \mygrid{image3}
  \end{tikzpicture}
  }%
  {\subcaption{subcap3}\label{sfig:c}}
\end{subfloatrow}  
}{\caption{A Minimal Working Example with three subfigures:~\ref{sfig:a}, \ref{sfig:b} and~\ref{sfig:c}}}
\end{mdframed}
\end{figure}

\begin{tikzpicture}[remember picture,overlay]
% Some arrows
\draw[->,line width=1.5pt,cyan!80!black,dashed] 
  ([yshift=-40pt,xshift=20pt]image2.north) |- +(0,80pt) -|
  ([yshift=-40pt,xshift=20pt]image3.north);
\draw[->,line width=1.5pt,orange!80!black] 
  ([yshift=-10pt,xshift=20pt]image2.west) |- 
  ([yshift=-10pt,xshift=20pt]image3.west);
\draw[->,line width=1.5pt,red!80!black] 
  ([xshift=20pt]image1.west) |- +(0,70pt) -| 
  ([yshift=20pt,xshift=30pt]image3.west);
\draw[->,line width=1.5pt,green!80!black,dashed] 
  ([yshift=20pt,xshift=-43pt]image1.east) |- +(0,-73pt) -|
  ([yshift=-15pt,xshift=-15pt]image3.east);
% Some labels
\node[anchor=north west,rotate=90,font=\ttfamily] 
  at (image1.north west) {Lane1: geneA};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-15pt] 
  at (image1.north west) {Lane2: geneB};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-30pt] 
  at (image1.north west) {Lane3: geneC};\end{tikzpicture}

\end{document}

在此輸入影像描述

註解掉三行後\mygrid{...},得到:

在此輸入影像描述

如果一般標題必須出現在框架之外,則可以將相應的參數留空(在這種情況下,是 external 的第二個參數\ffigbox),然後使用\RawCaption 外部環境mdframed。然而,為了保持同步性,figure計數器必須在開始時手動步進(如果標題位於物件之前,則沒有必要):

\documentclass[12pt]{scrartcl}
\usepackage{courier}
\usepackage[labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{floatrow}

\newcommand\mygrid[1]{%
  \begin{scope}[x={(#1.south east)},y={(#1.north west)}]
  \draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
  \foreach \x in {0,1,...,10} { \node [inner ysep=0pt,anchor=north,font=\tiny] at (\x/10,0) {\x}; }
  \foreach \y in {0,1,...,10} { \node [inner ysep=0pt,anchor=east,font=\tiny] at (0,\y/10) {\y}; }
  \end{scope}%
}

\begin{document}
\floatsetup[figure]{style=plain,capposition=bottom}
\begin{figure}
\begin{mdframed}[
  align=center,
  linecolor=black,
  fontcolor=black,
  backgroundcolor=white,
  %userdefinedwidth=0.9\textwidth,
  roundcorner=5pt,
  skipabove=10pt,
  skipbelow=10pt,
  leftmargin=0pt,
  innertopmargin=100pt,
  innerbottommargin=0pt, 
  innerlinewidth=0pt,
  middlelinewidth=0pt,
  outerlinewidth=1pt
]
\floatsetup[subfigure]{captionskip=10pt}
\ffigbox{%
\stepcounter{figure}
\begin{subfloatrow}[3]
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (image1) 
    {\includegraphics[width=3.8cm]{ctanlion}};
  %\mygrid{image1}
  \end{tikzpicture}
  }%
  {\subcaption{subcap1}\label{sfig:a}}%
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
    \node[anchor=south west,inner sep=0] (image2)  
      {\includegraphics[width=3.8cm]{ctanlion}};
  %\mygrid{image2}
  \end{tikzpicture}
  }%
  {\subcaption{subcap2}\label{sfig:b}}
  \ffigbox{%
  \begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (image3) 
    {\includegraphics[width=3.8cm,height=2cm]{ctanlion}};
  %\mygrid{image3}
  \end{tikzpicture}
  }%
  {\subcaption{subcap3}\label{sfig:c}}
\end{subfloatrow}  
}{}% empty second argument; the caption goes outside the frame
\end{mdframed}
\RawCaption{\caption{A Minimal Working Example with three subfigures:~\ref{sfig:a}, \ref{sfig:b} and~\ref{sfig:c}}\label{test}}
\end{figure}

\begin{tikzpicture}[remember picture,overlay]
% Some arrows
\draw[->,line width=1.5pt,cyan!80!black,dashed] 
  ([yshift=-40pt,xshift=20pt]image2.north) |- +(0,80pt) -|
  ([yshift=-40pt,xshift=20pt]image3.north);
\draw[->,line width=1.5pt,orange!80!black] 
  ([yshift=-10pt,xshift=20pt]image2.west) |- 
  ([yshift=-10pt,xshift=20pt]image3.west);
\draw[->,line width=1.5pt,red!80!black] 
  ([xshift=20pt]image1.west) |- +(0,70pt) -| 
  ([yshift=20pt,xshift=30pt]image3.west);
\draw[->,line width=1.5pt,green!80!black,dashed] 
  ([yshift=20pt,xshift=-43pt]image1.east) |- +(0,-73pt) -|
  ([yshift=-15pt,xshift=-15pt]image3.east);
% Some labels
\node[anchor=north west,rotate=90,font=\ttfamily] 
  at (image1.north west) {Lane1: geneA};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-15pt] 
  at (image1.north west) {Lane2: geneB};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-30pt] 
  at (image1.north west) {Lane3: geneC};
\end{tikzpicture}

\end{document}

在此輸入影像描述

CTAN 獅子由 Duane Bibby 繪製。

答案2

使用 PSTricks 和不使用subfigurePSTricks(或其變體)。我使用兩個數字只是為了簡單起見,因此您可以將其擴展到 3 個或更多!

請注意,PSTricks 中有多種連接線可供選擇,例如直線、圓弧、曲線等。

在此輸入影像描述

% filename is main.tex
% compile it with pdflatex -shell-escape main.tex
% ===============================================
\documentclass[pdf]{article}
\usepackage{pst-node}

\usepackage{graphicx}
\def\Scale{1.25}
\def\ShowGrid{top}

\newsavebox\IBox
\sbox\IBox{\includegraphics[scale=\Scale]{baby}}

\psset
{
    xunit=\dimexpr\wd\IBox/10,
    yunit=\dimexpr\ht\IBox/10,
}

\addtopsstyle{gridstyle}
{
    griddots=0,
    subgriddiv=2,
    gridwidth=0.2pt,
    subgridwidth=0.1pt,
    gridcolor=white,
    subgridcolor=cyan!50,
    gridlabels=4pt,
}

\def\SubFigLeft{%
\begin{pspicture}[showgrid=\ShowGrid](0,-1)(10,10)
    \rput[bl](0,0){\usebox\IBox}
    \pnode(4.2,4.8){Left}
\end{pspicture}}


\def\SubFigRight{%
\begin{pspicture}[showgrid=\ShowGrid](0,-1)(10,10)
    \rput[bl](0,0){\includegraphics[width=\wd\IBox]{adult}}
    \pnode(5.2,4.8){Right}
\end{pspicture}}


\begin{document}
Karl's student do not care about dashing patterns. Karl's students do not care about arrow tips. Karl' students, by the way, do not know what a transformation matrix is.
\begin{figure}[hbtp]
\centering
\begin{pspicture}[showgrid=false](0,-1)(21,10)
    \psframe[framearc=0.1,linecolor=orange,linewidth=2pt](-1,-2)(22,11)
    \rput[bl](0,-1){\SubFigLeft }
    \rput[bl](11,-1){\SubFigRight}
    \pcbar[linestyle=dashed,linecolor=magenta,linewidth=2pt,angle=90,arm=1]{->}(Left)(Right)
\end{pspicture}
\caption{The difference between angry and happy.}
\label{fig:Angry-Happy}
\end{figure}

Karl's student do not care about dashing patterns. Karl's students do not care about arrow tips. Karl' students, by the way, do not know what a transformation matrix is.
\begin{figure}[hbtp]
\centering
\def\ShowGrid{false}
\begin{pspicture}[showgrid=false](0,-1)(21,10)
    \psframe[framearc=0.1,linecolor=orange,linewidth=2pt](-1,-2)(22,11)
    \rput[bl](0,-1){\SubFigLeft}
    \rput[bl](11,-1){\SubFigRight}
    \rput(5,-1){(a) Angry}
    \rput(16,-1){(b) Happy}
    \pcarc[linestyle=dashed,linecolor=magenta,linewidth=2pt,angle=30]{->}(Left)(Right)
\end{pspicture}
\caption{The difference between angry and happy.}
\label{fig:Angry-Happy}
\end{figure}
\end{document}

相關內容