Closed zonglunli7515 closed 1 year ago
Hi Zonglun,
I can't really help you unless I know what you mean by "does not work". Can you provide a minimal example and the error message you're seeing?
Including caption and subcaption in the sample paper does not give an error on my end.
Hi Zonglun,
I can't really help you unless I know what you mean by "does not work". Can you provide a minimal example and the error message you're seeing?
Including caption and subcaption in the sample paper does not give an error on my end.
Hi, thanks for your speedy response. I include sth like below in the sample.tex:
\begin{figure} \centering \begin{subfigure} \centering \includegraphics[width=40mm]{sub_fig1} \end{subfigure} \begin{subfigure} \centering \includegraphics[width=50mm]{sub_fig2} \end{subfigure} \end{figure}
And I received the following error message:
You have created an environment (using \begin{…} and \end{…} commands) which is not recognized. Make sure you have included the required package for that environment in your preamble
Then I tried to place \usepackage{caption} and \usepackage{subcaption} in a right location but it didn't succeed.
That doesn't look like an error you would get from LaTeX. I think whatever editor you're using is trying to be clever, and misunderstanding the error.
I pasted your code into the sample, and I think you forgot to supply the width argument for subfigure. The following works for me:
\begin{figure}
\centering
\begin{subfigure}[b]{0.49\textwidth}
\centering
test
\end{subfigure}
\begin{subfigure}[b]{0.49\textwidth}
\centering
test
\end{subfigure}
\end{figure}
You can also consult the examples here for more information: https://www.overleaf.com/learn/latex/How_to_Write_a_Thesis_in_LaTeX_(Part_3)%3A_Figures%2C_Subfigures_and_Tables
[b]{0.49\textwidth}
Adding width argument will result in more errors from my end. I think the problem is caption and subcaption packages are not included in the preamble but I have no idea where to put them. Thanks for the help anyway.
If you give me a complete file that reproduces just your error (without anything else you're trying to do), I can have another look. Otherwise, I really can't help you without any specifics.
Hi,
Thanks again for offering help. Please find attached the demo.
Best, Zonglun
At 2023-02-23 15:43:26, "Tobias Kappé" @.***> wrote:
If you give me a complete file that reproduces just your error (without anything else you're trying to do), I can have another look. Otherwise, I really can't help you without any specifics.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
I think GitHub stripped the attachment from your email. Can you paste it here? (preferably in a code block)
I think GitHub stripped the attachment from your email. Can you paste it here? (preferably in a code block)
I attached a zip file but Github doesn't seem to recognize it. Please find below my sample.tex file:
`\documentclass{beamer} \usetheme{ucl} %%% Increase the height of the banner: the argument is a scale factor >=1.0 % \setbeamertemplate{banner}[ucl][1.5]
%%% Change the colour of the main banner %%% The background should be one of the UCL colours (except pink or white): %%% black,darkpurple,darkred,darkblue,darkgreen,darkbrown,richred,midred, %%% navyblue,midgreen,darkgrey,orange,brightblue,brightgreen,lightgrey, %%% lightpurple,yellow,lightblue,lightgreen,stone % \setbeamercolor{banner}{bg=darkpurple} % \setbeamercolor{banner}{bg=yellow,fg=black}
%%% Add a stripe behind the banner % \setbeamercolor{banner stripe}{bg=brightblue,fg=black}
%%% The main structural elements % \setbeamercolor{structure}{fg=black}
%%% Author/Title/Date and slide number in the footline % \setbeamertemplate{footline}[author title date]
%%% Puts the section/subsection in the headline % \setbeamertemplate{headline}[section]
%%% Puts a navigation bar on top of the banner %%% For this to work correctly, the each \section command needs to be %%% followed by a \subsection. Requires one extra compile. % \setbeamertemplate{headline}[miniframes] %%% Accepts an optional argument determining the width % \setbeamertemplate{headline}[miniframes][0.3\paperwidth]
%%% Puts the frame title in the banner %%% Won't work correctly with the above headline templates % \useoutertheme{ucltitlebanner} %%% Similar to above, but smaller (and puts subtitle on same line as title) % \useoutertheme[small]{ucltitlebanner}
%%% Gives block elements (theorems, examples) a border % \useinnertheme{blockborder} %%% Sets the body of block elements to be clear % \setbeamercolor{block body}{bg=white,fg=black}
%%% Include CSML logo on title slide % \titlegraphic{\includegraphics[width=0.16\paperwidth]{csml_logo}}
%%% Include CSML logo in bottom right corner of all slides % \logo{\includegraphics[width=0.12\paperwidth]{csml_logo}}
%%% Set a background colour % \setbeamercolor{background canvas}{bg=lightgrey}
%%% Set a background image %%% Some sample images are available from the UCL image store: %%% https://www.imagestore.ucl.ac.uk/home/start % \setbeamertemplate{background canvas}{% % \includegraphics[width=\paperwidth]{imagename}}
%%%%%% Some other settings that can make things look nicer %%% Set a smaller indent for description environment \setbeamersize{description width=2em} %%% Remove nav symbols (and shift any logo down to corner) \setbeamertemplate{navigation symbols}{\vspace{-2ex}}
\title{test} \author{author} \institute[UCL]{% Department of X \ % University College London } \date{6th March 2023}
\begin{document}
\begin{frame} \titlepage% \end{frame}
\begin{frame}{figure test}
\begin{figure}
\centering
\begin{subfigure}
\centering
\includegraphics[width=40mm]{images/fig1_name}
\end{subfigure}
\begin{subfigure}
\centering
\includegraphics[width=50mm]{images/fig2_name}
\end{subfigure}
\end{figure}
\end{frame}
\end{document}`
I didn't modify any other files.
Thanks a lot!
You are still not including the subcaption package, and the width argument to the subfigures is still missing.
This works on my machine:
\documentclass{beamer}
\usetheme{ucl}
%%% Increase the height of the banner: the argument is a scale factor >=1.0
% \setbeamertemplate{banner}[ucl][1.5]
%%% Change the colour of the main banner
%%% The background should be one of the UCL colours (except pink or white):
%%% black,darkpurple,darkred,darkblue,darkgreen,darkbrown,richred,midred,
%%% navyblue,midgreen,darkgrey,orange,brightblue,brightgreen,lightgrey,
%%% lightpurple,yellow,lightblue,lightgreen,stone
% \setbeamercolor{banner}{bg=darkpurple}
% \setbeamercolor{banner}{bg=yellow,fg=black}
%%% Add a stripe behind the banner
% \setbeamercolor{banner stripe}{bg=brightblue,fg=black}
%%% The main structural elements
% \setbeamercolor{structure}{fg=black}
%%% Author/Title/Date and slide number in the footline
% \setbeamertemplate{footline}[author title date]
%%% Puts the section/subsection in the headline
% \setbeamertemplate{headline}[section]
%%% Puts a navigation bar on top of the banner
%%% For this to work correctly, the each \section command needs to be
%%% followed by a \subsection. Requires one extra compile.
% \setbeamertemplate{headline}[miniframes]
%%% Accepts an optional argument determining the width
% \setbeamertemplate{headline}[miniframes][0.3\paperwidth]
%%% Puts the frame title in the banner
%%% Won't work correctly with the above headline templates
% \useoutertheme{ucltitlebanner}
%%% Similar to above, but smaller (and puts subtitle on same line as title)
% \useoutertheme[small]{ucltitlebanner}
%%% Gives block elements (theorems, examples) a border
% \useinnertheme{blockborder}
%%% Sets the body of block elements to be clear
% \setbeamercolor{block body}{bg=white,fg=black}
%%% Include CSML logo on title slide
% \titlegraphic{\includegraphics[width=0.16\paperwidth]{csml_logo}}
%%% Include CSML logo in bottom right corner of all slides
% \logo{\includegraphics[width=0.12\paperwidth]{csml_logo}}
%%% Set a background colour
% \setbeamercolor{background canvas}{bg=lightgrey}
%%% Set a background image
%%% Some sample images are available from the UCL image store:
%%% https://www.imagestore.ucl.ac.uk/home/start
% \setbeamertemplate{background canvas}{%
% \includegraphics[width=\paperwidth]{imagename}}
%%%%%% Some other settings that can make things look nicer
%%% Set a smaller indent for description environment
\setbeamersize{description width=2em}
%%% Remove nav symbols (and shift any logo down to corner)
\setbeamertemplate{navigation symbols}{\vspace{-2ex}}
\title{test}
\author{author}
\institute[UCL]{%
Department of X \ %
University College London
}
\date{6th March 2023}
\usepackage{subcaption}
\begin{document}
\begin{frame}
\titlepage%
\end{frame}
\begin{frame}{figure test}
\begin{figure}
\centering
\begin{subfigure}{0.49\textwidth}
\centering
test
\end{subfigure}
\begin{subfigure}{0.49\textwidth}
\centering
test
\end{subfigure}
\end{figure}
\end{frame}
\end{document}
Note the use of \usepackage{subcaption}
before \begin{document}
, and the {0.49\textwidth}
after `\begin{subfigure}.
I've removed the \includegraphics
commands, because I did not have those files on my machine.
{0.49\textwidth}
I did this before but it only worked for subfloat but not subfigure. I will dig around, thanks for the help.
Hi, I was trying to add subfigure. Where should I place \usepackage{caption} and \usepackage{subcaption}? I tried multiple locations but none of them worked. As I understand, these should be added in preamble but it does not seem very clear to me where it is. Thanks in advance for the help.