In this video you will learn latex of figure environment
anything which starts with backslash begin and ends at
backslash end is called an environment figure is an
environment sub figure is also an environment. So the first
question is when we use soft trigger environment, in some
cases, we want to show two images side by side, or
sometimes one at the top of the other image. But we want to have
a separate caption or description of each of those
image. And also we want to have a main description of both of
them a main caption, so in this situation, we will use a finger
environment and inside that finger environment,
we have to use two sub trigger environments.
And this is what is happening in this image. I will show you in a
minute how we can use these finger and sub trigger
environments. But first I want to explain various parts of this
figure. There are three captions Eb and figure one, no, these
captions are automatically assigned by latech. This image
has been taken from a document and this is the first image of
the document, the first finger is assigned a caption figure one
colon, now we have three captions to four sub figures and
one for the main figure. In each of these captions, there are
three main components This is the label, similarly this B and
figure one colon, these are labels, then there is a
separation between the text and the label. This is called label
separation or label Sep. And then there is text for each one
of them. If you look carefully, you will notice some
differences. This is completely bold, while the text is all
capital for this sub figure, in sub figure B. This B is slanted
and it holics. So two types of formatting has been applied to
this label of this caption. And then text itself is bolded. The
main figure has label and then a colon. And the text is bold and
label is also bold. So this is not a well planned image. But I
put this here on purpose, just to show you that we can have a
full control of all these captions of the main image and
of sub images or sub figures in latech. And this is what we are
going to learn in this video. Let's talk about another
functionality which we want to achieve in this video. And this
is by using a package which is called sub caption package. And
what this package allows us to do is to control the sub
captions. This is an example which I'm showing here. This is
a finger environment and inside the finger environment, I'm
using two sub fingers, I'm not using any caption for the main
finger, only two captions, one for each of the sub finger. So I
want to show the left hand side image as a larger image. While I
want to show a very small image on the right hand side. This
sometimes is a requirement that we want to have two different
size images. And we can do this by allocating, let's say 70%
portion to this image and 30% to this. But what happens is that
when I put a caption on this, by using only the caption package,
which we use for sub figure caption controls, then this
caption tries to fit in that 30% area. This is not what I want
because this does not look good. On the right hand side is the
way I want to have this sub caption. I want to get more
space for this sub caption without changing the allocated
space for left and right sub figures. So this control on sub
captions is provided by sub caption packet. So this is not
what we want, we want to have a sub caption of this time. Now
once you know that there are three main components of a
caption, and now it's time to learn how we can set some
options for those three parts. So there are two ways to set
values for those three components. One is at the
document level, you know that at the beginning of any latech
document when we use use package captions, we can set the options
for these three parts of a caption inside these square
brackets, we can set the font for the label, we can set the
label separation and we can set the text font if you set the
options at document level. This will affect
all the figures and sub figures in your document.
But there is another way of setting these options
and
that is at an environment level. You can set these options within
a finger environment or within a sub trigger environment by using
this command backslash caption setup. One thing you should
notice here is that when you set the options in the package
command, you set options in the square brackets because the name
of the package is written in the curly brackets and options are
in the square bracket. But when you set the options using
caption setup command, the options are written inside the
curly brackets. Now what are the options available for label font
or label separation, our text font and know let us see what
options do we have for label fonts and label separations. For
label phones we have these options nearly 15 options, skip
size, actually a T is missing. From here it's a typing misc
mistake, it's script size, not script size, then we have
footnote size, normal size, small, large, large with the
capital L, which is a little bit larger than this large than
upright italica slanted small caps, medium series, bold series
Roman sans serif are typewriter style. So these are some of the
font options available. And you can also use these font options
for text as well. Then for level separation, we have these
options, none means that you don't want any separation
between the label and the text, then you can have a colon, you
can have a period or a full stop, you can also have space,
our quad quad is a space based on the current font. So this is
more appropriate than this space, then new line, you can
start the text from the next line,
then also you can have a dash at the end.
So these are some of the options available in caption package. So
you can set more than one options.
For label font. As you can see,
that SL means slanted it means it Alec and I have shown you
this in a previous example, our sub figure B was having these
options
slanted and metallics.
So you only have to learn these two commands of setting the
options. And then if you know the options, you can put the
values here and you can have a complete control on your sub
figures and figures inside the latech document. And now I will
show you in a latech document how we can use these options.
Now let's have a look at the latest code. And if you already
familiar with my videos, you know that I always try to use
the minimum amount of code required to demonstrate
something and in order to demonstrate figure in some
bigger environments, I only have to use these three packages.
Graphics packages required when I have to use this include
graphics command caption is required to set the captions for
the sub figures and the main figures and sub caption package
is used to manipulate the caption of the sub figure. So
this is one figure and vironment and inside that figure we have
two sub figures. And let me explain this code a little bit,
I am using the article cloud then begin document and then
here is the point from where figure environment starts and
this is the last line of the outer figure environment and
inside this figure environment, we have two sub fingers. So,
this is the first sub trigger environment begins of figure two
and some end sub figure and then the second sub figure
environment starts here and ends here. We have caption for sub
figure, we have caption for second sub finger and we have
caption for main figure. Now the most important thing is first of
all, you have to decide how many images you want to have in your
finger environment side by side. So this whole width of the page
is line width. And because I am using only two images, so here I
have to assign point five backslash linewidth in the sub
trigger environment. And remember one thing that sub
trigger is the outer environment around this image and this image
itself also has a width option here which you can give inside
the include graphics and I will show you in a minute. How does
it change. So first of all, I decided that I want to suffer
bigger environments. So 50% point five divided by line width
means 50% of the line width I am giving to the first sub figure
and 50% of the line width I am allocating to the second sub
figure by using this option 0.5 backslash linewidth if you are
using three sub figures you can have point 3.3 and point three.
If you're using four sub figures, you can have point two
five for each one of these environments. One option is here
and the second option in the include graphic you can see that
we also have width is equal to backslash line width. This is
only for the image and if you choose These two, for example,
point five. So let us change this second sub figure 2.5. And
see what happens if I compile now and then regenerate the PDF.
Now as you can see that the sub finger environment is taking the
half of the line width, but the image itself is taking half of
that. So in practice, it means that the image size will be
reduced to half if you set the option inside the include
graphics. So, this is not what I want, I want this to be taking
the full space of half of the page. So, let us recompile and
create the PDF. Now we are back because I am only using same
file same image file for both sub fingers, the name of the
file is image dash one dot png. So there is no problem because
the size of the image is same, but if the size of the image is
not same, and you can check the size by opening the image in
paint, then click on File and then properties. And you can see
if the pixel is selected here you can see that this image is
395 pixel wide and 330 pixel height. So this is all you can
check the size. But the point is because the size is same, it is
actually the same image. So there is no problem. Captions
are aligned perfectly. And everything is perfect. But let
us know change one of the image to image dash two, I have
another image in the same folder and I compile. And no I didn't
read the PDF No, although the images look fine. But no, if you
look, the captions are
not aligned.
And this is because this image has a different size. And by
default, it tries to align at the bottom. So if you want to
align these captions, what you need to do is just insert figure
options put t mean stop. So if I put t here in both of the sub
figure options, and now if I recompile and generate the PDF
no captions are aligned no you It seems that the images are off
center. But actually it's not. If I take the full page images
are perfectly centered It is only because I am trying to show
you a bigger zoomed in image. So therefore, it looks like it's
not
centered.
The next thing is I want to put the options for caption label
this separation and text font. So as I mentioned earlier, let
us first put the option at document level where we are
using the package. So before this caption, I can start and
close a square bracket and know I can put label font equals and
whatever I want. For example, let's say slanted SL and it
leaks it then a comma and then label separation equals let us
put a colon here and then a comma and then text font equals
let us put a border. So these are the options now for all of
the figures and sub figures and Let us compile this and now I
create the PDF zoom full page and now zoom in a little bit.
Now, as you can see that now, all the labels are slanted and
italics A B and figure one and all the text is bold. Now, let
us see how we can change the option within any specific
environment inside the South figure environment the first one
I put the command caption setup start and close curly brackets
now I can just
cut from here and
paste it here
no only the option for this sub figure will change and if I
compile now, regenerate the PDF and zoom in a little bit. Now as
you can see that only the first sub figure has slanted and
italie label and bold text the rest are all having the default
values. So let us copy this command to second sub figure
environment is based here and no i instead of slanted and italics
I give small capital and if I compile now, dejan rate and now
as you can see that this label B is written as small capital
fashion while the sub figure he has a different format and the
main figure has the default format. So this is how you can
change all the formatting options. Now, let us assume that
you want to put these two figures in a vertical manner. So
the simple solution to that is just put a blank line between
these two and if I compile now and regenerate the PDF as you
can see that now we have one free Good environment. But
inside that we have two sub triggers
one at the top of other.
Sometimes what happens if you remove this blank line, and you
compile, and I regenerate the PDF, as you can see that it is
still the same. So in that case, what you can do is you can just
put your cursor after this first sub figure end statement, and
then press Delete. And then if I recompile now and generate the
PDF, it will be fine. So I don't know why this happens. But
sometimes it happens that when you insert a line, put them
vertical, then you decide to put them horizontal, you have to do
this. But other than that, it's a very good package. And it's
very useful, you can have full control on your images in figure
in software environments. No, the last thing I want to show is
that this sub caption, how we can use sub caption and to
demonstrate that I change this to a logo image, a very small
image.
And if I no recompile, this
and no, as you can see that this image has a very small size,
this has a very large size compared to this one. But
because I am allocating equal width to these two images, they
appear same, but this is not what I want, I want to show this
image in a very small area. So what I can do is I can assign
this 2.7 and this 2.3. And if I recompile. Now I know this image
is only occupying 30% of the line Wait, which is fine. But
here is the problem, this does not look very good. And we can
accommodate this text in one line, which will look good. So
to do that, we have to use this sub caption package, because
this will help us to manipulate this part. So to do that, what
we need to do is just comment this caption. And I will just
copy this text from here. And the command I have to put is
called sub caption box, backslash sub caption box. And
then I have to start curly bracket, then a square bracket
and then a curly bracket. So this is the format of this
command. So there are three brackets here. So in the first
bracket, you put the caption text, so I have already copied
it, I just paid paste it here, you can, if you want to put a
label just like this, you also have to put a label inside this
in the second square bracket, you will put the size of the
caption which you want to use. For example, I say that my
caption should occupy six centimeter of this page I can
put here and in the third curly bracket, we have to use this
include graphics command, so I just remove the second bracket
and put it here and then I have to put only the name of the
image. So I can just remove this remove this and remove
everything from here. Just like that. So in the third curly
bracket we have backslash include graphics, and then
another set of curly brackets, in which I put the name of the
image. And then I just close this so this is the command you
use to adjust the width of this sub caption. And if I compile
now and generate the PDF, now as you can see that my caption has
taken six centimeters. So what I should do is maybe I should
allow this to seven centimeter instead of six still, it needs a
little bit of space. So I might give it eight centimeter and try
and no it's fine. So this you have to do a little bit hit and
trial. Because we don't know how much space this text is going to
take nor this caption command you can delete this I have
commented this already, but you can simply delete this it's not
required. So this is how you use finger and sub finger
environment and manipulate the options whether on the document
level or in an individual environment.