subfloatrow
我努力寻找、和添加箭头的组合overpic
,以便使用 注释导入的图像tikz
,但没找到。这类图像通常出现在生物学领域,它们可能用于蛋白质印迹或凝胶电泳等……其想法始终相同;就是获取带有文本注释的多幅图像(Courier 非常适合此处),并且经常使用优雅而简单的箭头指向图像中感兴趣的特定波段或点。
除非您报告更好的,否则不推荐!
overpic
:针对此类文本注释的一个非常好的解决方案floatrow
:在处理子浮点数(图形和表格)以及子标题和许多其他功能方面,AFIK 是最好的mdframed
:一个功能丰富的框架控制包tikz
:用于绘制箭头和图形的无注释包(tikz 粉丝!)
请在回答中避免出现这些情况
subfig
: 过时的subfigure
:支持但未维护subcaption
:很好,但是它的手册会指导你使用更好的,即floatrow
用于更复杂的子浮点数 的 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{...}
,得到:
如果一般标题必须出现在框架之外,则可以将相应参数留空(在本例中为 outer 的第二个参数\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 和不使用subfigure
PSTricks(或其变体)。我使用两个数字只是为了简单起见,这样您就可以将其扩展到 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}