TransWikia.com

Fit decoRule to picture lentgh

TeX - LaTeX Asked by Alexis Charalambis on March 9, 2021

I am using decoRule to draw a line under my figure and before the caption. I would like to have this line with the same lenght of my picture.
enter image description here

the code I am using is the following:

 begin{figure}
  begin{subfigure}[b]{0.6textwidth}
    includegraphics[width=textwidth]{stereolithography}
       label{fig:sla}
  end{subfigure}
  %
  begin{subfigure}[b]{0.6textwidth}
    includegraphics[width=textwidth]{dlp1}
    label{fig:dlp}
  end{subfigure}
  decoRule
  caption[Schematic of Vat Photopolymerization.]{a) Schematic of top-cured laser based machine, Stereolithography. b) Schematic of bottom-cured Digital Light Processing (DLP) machine. Courtesy of 3D Printing Industry parencite{3d_printing_industry_2016}.}
end{figure}

2 Answers

As it stands, your question is unanswerable since none but you know how decoRule is defined.

There is a decorule defined by the decorule package. However, it looks nothing like the rule in your image, so presumably it isn't that. In fact, the rule in your image looks like a bog-standard rule.

If so, then you can just set vrule to the appropriate width - for one example.

The main issue is that your code will give bad boxes because you cannot fit 120% of the textwidth plus an additional space into a textwidth text block and expect things to work nicely.

The following uses chngpage to adjust the left and right margins for the image and rule, reverting to the standard settings for the caption. This eliminates bad boxes.

Obviously, I changed the images. I'm sure you'll agree these are a considerable improvement. A pedant might quibble over the relevance of the caption and the transformation of the citation into a question mark. However, sometimes you just have to take your cats where you can find them and damn the critics.

documentclass{article}
usepackage{graphicx,subcaption,chngpage,calc}
newlengthfulltextwidth
setlengthfulltextwidth{textwidth}
newlengthfullpicwidth
setlengthfullpicwidth{1.2textwidth+2fboxsep+2fboxrule}
begin{document}
begin{figure}
  begin{adjustwidth}{-.1fulltextwidth-fboxrule-fboxsep}{-.1fulltextwidth-fboxsep-fboxrule}
    fbox{%
      begin{subfigure}[b]{0.6fulltextwidth}
        includegraphics[width=textwidth]{cauldron}
        label{fig:sla}
      end{subfigure}%
      begin{subfigure}[b]{0.6fulltextwidth}
        includegraphics[width=textwidth]{cathod}
        label{fig:dlp}
      end{subfigure}%
    }
    par
    vrule height 1pt depth 1pt width fullpicwidth
    par
  end{adjustwidth}
  caption[Schematic of Vat Photopolymerization.]{a) Schematic of top-cured laser based machine, Stereolithography. b) Schematic of bottom-cured Digital Light Processing (DLP) machine. Courtesy of 3D Printing Industry cite{3d_printing_industry_2016}.}
end{figure}
end{document}

cauldron and cats

Answered by cfr on March 9, 2021

You could center the horizontal line by using centering. You also need to leave an empty line before placing the centering command for it to not center all of your subfigures. So your code should look like this.

begin{figure}
 begin{subfigure}[b]{0.6textwidth}
   includegraphics[width=textwidth]{stereolithography}
      label{fig:sla}
 end{subfigure}
 %
 begin{subfigure}[b]{0.6textwidth}
   includegraphics[width=textwidth]{dlp1}
   label{fig:dlp}
 end{subfigure}

% Leave an empty line then add centering before adding decoRule
 centering
 decoRule 
 caption[Schematic of Vat Photopolymerization.]{a) Schematic of top-cured laser based machine, Stereolithography. b) Schematic of bottom-cured Digital Light Processing (DLP) machine. Courtesy of 3D Printing Industry parencite{3d_printing_industry_2016}.}
end{figure}

I am not sure why it works. It probably has to do with new paragraphs and stuff...

Answered by Desmond on March 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP