0

I have several subfigures in a figure. There is one image that has a much lower vertical width than the others and it is placed at the bottom of the subfigure region. Also the caption is placed below both figures(I have a nx2 grid). How can I align/center a subfigure vertically with respect to the others and how can I get the caption to apply only the subfigure it is in?

X-------X
|       |
| Fig 1 |   X-------X
|       |   | Fig 2 | 
X-------X   X-------X
    Fig 2 caption 

But I would like

X-------X
|       |   X-------X
| Fig 1 |   | Fig 2 | 
|       |   X-------X
X-------X  Fig 2 caption
1

Perhaps something like this.

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\begin{figure}
\includegraphics[width=.4\linewidth,valign=c]{example-image-10x16} %valign key is from adjustbox
\begin{minipage}{.5\linewidth}
\centering
\includegraphics[width=.8\linewidth]{example-image}
\caption{Bla bla}
\end{minipage}
\end{figure}
\end{document}
  • Thanks. Works but 2nd figure is much smaller than it should(about 0.5, which is what i'm using, as that is the other figures with factor). if I set it to 1 then it goes off the page to the right. When I remove centering it works but the caption is shifted to the right still. Not a big deal because I can add text to the image instead of using a caption. I still have first image wrapped in a subfigure though and maybe that is the reason? – AbstractDissonance Dec 27 '16 at 8:22
  • @AbstractDissonance And this is why a minimal example is nice to have. With a proper example I wouldn't have had to make any assumptions about your setup, and I could have done something that works properly (if I was able to, that is). I don't quite understand what is wrong, though I would guess it has to do with the width of the minipage. But add an example to your question, and I can have a look. (Incidentally, if my answer doesn't work properly, why do you accept it instead of waiting for improvements/better answers?) – Torbjørn T. Dec 27 '16 at 8:28
  • Too bad because you assume I can provide a MWE. I would have to post about 100000+ lines of code. I use lualatex to generate most of the code using a custom built framework that you couldn't figure out if you tried. instead, you should just make the assumptions and go off what I say and do the best you can and I'll try to interpret your answers. – AbstractDissonance Dec 27 '16 at 8:31
  • @AbstractDissonance Indeed sounds complicated, but why do you need to post everything? If you know what kind of code is generated, then can't you just make something like what I posted, but with the structure that you're generating? – Torbjørn T. Dec 27 '16 at 8:36
  • not really because if I do then it would work just like your solution(which partially worked anyways). The figure its generated by lua code and processed in a weird way and is obviously creating some weird conflict with the caption. The code that generates it is heavily interdependent with the whole framework so it would be impossible to split up. Why the caption is being shifting is odd but probably something simple. It is not a huge issue. Maybe I can simply do another minipage and stack the 2nd image with the caption so they are not in the same environment? – AbstractDissonance Dec 27 '16 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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