Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to do some kind of figures, typical of Western blotting in biology. The figures are enclosed with a frame using mdframed package. A MWE example is shown below. In the middle of creating this panel of figures, few issues arose. The position of the figure below was displaced, the code was cluttered, and I said that it would be even more cluttered if I would continue doing things like I've done. Therefore, I decided to ask the help of the community before ending up with awful lines of codes.

What is needed:

  1. put a number just beside (at the right side) each arrowhead (there are 6 of them) to indicate the size of the migrated protein, e.g., numbers like 10kDa, 15kDa, 25kDa, 35kDa, 40kDA, 55kDa (from bottom to top). It would be helpful if the code would treat this as relative coordinates and not absolute ones (really appreciate that, because I would apply the same arrowheads, with their corresponding number labels above, to the rest figures exactly).
  2. The labels above the blots should stay 45 degrees rotated, had they been 90 rotated no displacement of the below figure would occur, given the lines of code below. So what should be done, in this case, to avoid this unwanted behavior of displacement?
  3. Application of the 45 degree-rotated labels to the other two figures the same way and to make sure that this would not lead to similar displacements of figures.
  4. It would be helpful, indeed, to provide a shortcut code in TikZ so that to reduce the amount of the already cluttered code needed to annotate such pictures.
  5. The label beta-actin should be put on the left side of the small figure below each of the larger figures as shown in the MWE. This caused a further displacement of the smaller figure (if you compare the figure c of MWE with the actual figure c). This label should be applied for the rest two above figures, exactly the same manner, without causing any side effects.

MWE code:

\documentclass{scrartcl}
\usepackage{xcolor} 
\usepackage{caption}
\usepackage{floatrow}   
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees,calc,decorations.markings}

\begin{document}
\begin{figure}
\begin{mdframed}[
  align=center,
  linecolor=black,
  fontcolor=black,
  backgroundcolor=white,
  userdefinedwidth=0.9\textwidth,
  roundcorner=5pt,
  skipabove=0pt,
  skipbelow=0pt,
  leftmargin=0pt,
  innerleftmargin=20pt,
  innerrightmargin=0pt,
  innertopmargin=5pt,
  innerbottommargin=5pt, 
  innerlinewidth=0pt,
  middlelinewidth=0pt,
  outerlinewidth=1pt]
\floatsetup[subfigure]{captionskip=10pt}
%===================== upper two subfigures ================
\begin{minipage}{.44\textwidth}
    \begin{subfigure}{\linewidth}
    \centering
    \begin{tikzpicture}[remember picture]
     \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (a) {\includegraphics[width=5cm, height=5cm, clip= true, trim = 0 0 0 0]{whatever}};
    \end{tikzpicture}
    \begin{tikzpicture}[remember picture]
    \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (asupp) {\includegraphics[width=5cm,height=.75cm, clip= true, trim = 0 0 0 0]{whatever}};
    \end{tikzpicture}
    \caption{Image}
    \label{fig:mwe:a}
    \end{subfigure}\\[0ex]
\end{minipage}
\begin{minipage}{.44\textwidth}
    \begin{subfigure}{\linewidth}
    \centering
    \begin{tikzpicture}[remember picture]
        \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (b) {\includegraphics[width=5cm, height=5cm, clip= true, trim = 0 0 0 0]{whatever}};
    \end{tikzpicture}
    \begin{tikzpicture}[remember picture]
        \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (bsupp) {\includegraphics[width=5cm, height=.75cm, clip= true, trim = 0 0 0 0]{whatever}};
    \end{tikzpicture}
    \caption{Image}
    \label{fig:mwe:b}
   \end{subfigure}
\end{minipage}
\vfill
%===================== the one below subfigure ================
\begin{minipage}{.94\textwidth}
  \begin{subfigure}{\linewidth}
  \centering
  \begin{tikzpicture}[remember picture]
 \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (c) 
    {\includegraphics[width=5cm, height=5cm, clip= true, trim = 35 0 0 0]{whatever}};
  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,.2); %arrowhead

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,1.6);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,3);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,3.6);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,4.1);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,4.6);

    % add labels
    \node [anchor=south west, xshift=35pt, rotate=45] at (c.north west) {Lane1 ABC};

    \node [anchor=south west, xshift=70pt, rotate=45] at (c.north west) {Lane2 DEF};

    \node [anchor=south west, xshift=105pt, rotate=45] at (c.north west) {Lane3 GHI};

    \node [anchor=south west, xshift=135pt, rotate=45] at (c.north west) {Lane4 JKL};
  \end{tikzpicture}
  \\[0ex]
  \begin{tikzpicture}[remember picture]
   \node [anchor=south west, draw=orange,line width=5pt, inner sep=0pt] (csupp) {\includegraphics[width=5cm, height=.75cm, clip= true, trim = 0 0 0 0]{whatever}};
   \node[anchor=south west,font=\ttfamily,xshift=-50] at (csupp.south west) {$\beta$-actin};
  \end{tikzpicture}
  \caption{Image}
  \label{fig:mwe:c}
  \end{subfigure} 
\end{minipage}

\end{mdframed}
\RawCaption{\caption{General Caption.}
\label{fig:mwe}}
\end{figure}

\end{document}

which yields:
enter image description here

The figure c, for instance, looks like this in the original image:
enter image description here

Update:
Code is updated now so that MWE works using demo images by using \usepackage[demo]{graphicx} option.

share|improve this question
    
Could you edit your question to provide the two blot images without the frames? –  Jake Dec 6 '13 at 11:28
    
pls see the code added, is that what was meant? I hope. –  doctorate Dec 6 '13 at 11:37
    
No, sorry, I meant the actual images. –  Jake Dec 6 '13 at 11:45
    
Ah, but removing them would not remedy the displacement problem. These frames just make the blots look nicer. –  doctorate Dec 6 '13 at 11:50
1  
You can set an appropiate bounding box for the tikz figures. Anywhing drawn out of that bounding box would not be "seen" by tex as part of the figure, and thus not taken into account for alignment. Of course this can cause overlap of those "out of bounding box areas" if two figures are put too close. –  JLDiaz Dec 6 '13 at 13:02

1 Answer 1

up vote 2 down vote accepted

Expanding my comment, as requested by the OP, the idea is to force the bounding box of each figure to the region containing the included figure. This is easy, because the figure is included in a node.

If the name of the node is c, for example, you only have to include the following path as part of the tikzpicture:

\path[use as bounding box] (c.south west) rectangle (c.north east);

This rectangle is what is taken into account by TeX in order to reserve space for the figure, and thus for alignment. All what is drawn outside of that rectangle, "spills out" the tikz picture, and can overlap the surrounding text. To avoid this you have to set manually some vertical or horizontal space around the tikz picture.

In your example, subfigure (c) has to be "manually" shifted down to avoid the rotated labels at top to collide with figures (a) and (b). This means to insert some \vskip between them.

This is the complete code (the changes are marked with % <=== comments)

\documentclass{scrartcl}
\usepackage{xcolor}
\usepackage{caption}
\usepackage{floatrow}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees,calc,decorations.markings}

\begin{document}
\begin{figure}
\begin{mdframed}[
  align=center,
  linecolor=black,
  fontcolor=black,
  backgroundcolor=white,
  userdefinedwidth=0.9\textwidth,
  roundcorner=5pt,
  skipabove=0pt,
  skipbelow=0pt,
  leftmargin=0pt,
  innerleftmargin=20pt,
  innerrightmargin=0pt,
  innertopmargin=5pt,
  innerbottommargin=5pt,
  innerlinewidth=0pt,
  middlelinewidth=0pt,
  outerlinewidth=1pt]
\floatsetup[subfigure]{captionskip=10pt}
%===================== upper two subfigures ================
\begin{minipage}{.44\textwidth}
    \begin{subfigure}{\linewidth}
    \centering
    \begin{tikzpicture}[remember picture]
     \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (a) {\includegraphics[width=5cm, height=5cm, clip= true, trim = 0 0 0  → 0]{whatever}};
    \end{tikzpicture}
    \begin{tikzpicture}[remember picture]
    \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (asupp) {\includegraphics[width=5cm,height=.75cm, clip= true, trim = 0  → 0 0 0]{whatever}};
    \end{tikzpicture}
    \caption{Image}
    \label{fig:mwe:a}
    \end{subfigure}\\[0ex]
\end{minipage}
\begin{minipage}{.44\textwidth}
    \begin{subfigure}{\linewidth}
    \centering
    \begin{tikzpicture}[remember picture]
        \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (b) {\includegraphics[width=5cm, height=5cm, clip= true, trim = 0   → 0 0 0]{whatever}};
    \end{tikzpicture}
    \begin{tikzpicture}[remember picture]
        \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (bsupp) {\includegraphics[width=5cm, height=.75cm, clip= true,      → trim = 0 0 0 0]{whatever}};
    \end{tikzpicture}
    \caption{Image}
    \label{fig:mwe:b}
   \end{subfigure}
\end{minipage}
\vskip 2cm  % <==== Needed to "make room" for the rotated labels
%===================== the one below subfigure ================
\begin{minipage}{.94\textwidth}
  \begin{subfigure}{\linewidth}
  \centering
  \begin{tikzpicture}[remember picture]
 \node [anchor=south west,draw=orange,line width=5pt, inner sep=0pt] (c)
    {\includegraphics[width=5cm, height=5cm, clip= true, trim = 35 0 0 0]{whatever}};
  \path[use as bounding box] (c.south west) rectangle (c.north east);  % <===== 
  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,.2); %arrowhead

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,1.6);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,3);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,3.6);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,4.1);

  \path [decoration={markings, mark=at position 1 with {\arrow[scale=2,rotate=180]{latex}}}, decorate] (5.1,4.6);

    % add labels
    \node [anchor=south west, xshift=35pt, rotate=45] at (c.north west) {Lane1 ABC};

    \node [anchor=south west, xshift=70pt, rotate=45] at (c.north west) {Lane2 DEF};

    \node [anchor=south west, xshift=105pt, rotate=45] at (c.north west) {Lane3 GHI};

    \node [anchor=south west, xshift=135pt, rotate=45] at (c.north west) {Lane4 JKL};
  \end{tikzpicture}
  \\[0ex]
  \begin{tikzpicture}[remember picture]
   \node [anchor=south west, draw=orange,line width=5pt, inner sep=0pt] (csupp) {\includegraphics[width=5cm, height=.75cm, clip= true, trim =   → 0 0 0 0]{whatever}};
   \path[use as bounding box] (csupp.south west) rectangle (csupp.north east);  % <======
   \node[anchor=south west,font=\ttfamily,xshift=-50] at (csupp.south west) {$\beta$-actin};
  \end{tikzpicture}
  \\[0ex]
  \caption{Image}
  \label{fig:mwe:c}
  \end{subfigure}
\end{minipage}

\end{mdframed}
\RawCaption{\caption{General Caption.}
\label{fig:mwe}}
\end{figure}

\end{document}

And this is the result:

Result

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.