2

I have the following table:

\begin{table}[hbt]
\centering
\tabcolsep=0.3cm
\caption{Gram Negative Bacteria.}{\cite{Bacterial_Classification}}
\label{Tab:Gram Negative Bacteria}
\renewcommand{\arraystretch}{1.5}
\small
\begin{tabularx}{\textwidth}{ p{5em} >{\raggedright\arraybackslash}X p{5em} p{5em} >{\raggedright\arraybackslash}X >{\raggedright\arraybackslash}X }
    \toprule
    \textbf{Name} & \textbf{Morphology} & \textbf{O\textsubscript{2} Require\-ments} & \textbf{Commensal} & \textbf{Reservoirs / Sites \-of colonization, Transmission} & \textbf{Types of Infections} \\ \midrule
    Entero\-bacteriaceae (E. coli, klebsiella, salmonella, shigella) & Rods & facultative anaerobe & Some species & GI tract, animals / Endogenous, fecal oral & Diarrhea, uninary tract, food poisoning, sepsis \\
    Bacteroides & Rods & anaerobic & Yes & GI tract / Endogenous & Abscesses \\
    Pseudomonas & Rods & aerobic & No & Water, soil / Endogenous, breach of skin barrier & Infections in immunocompromised hosts, Cystic Fibrosis \\
    Vibrio (cholera) & Rods, curved shap & micro\-aerophilic & No & Water / Contaminated food, water & Diarrhea \\
    Campylobac\-ter & Rods, curved shape & micro\-aerophilic & No & Food / Ingestion of contaminated food & Diarrhea, Bacteremia \\
    Legionella & Rods, poorly stained & micro\-aerophilic & No & Water Inhalation of aerosol & Pneumonia, febrile illness \\
    Neisseriam & Cocci, kidney-bean shaped & Micro\-aerophilic & No (\textit{N. meningitidis} sometimes) & Humans / Sexual, aerosol & Meningitis, pelvic inflammatory disease \\
    Hemophilus & Coccobacillary-pleomorphic & facultative anaerobe & Some species & Respiratory tract / Endogenous, aerosol & Respiratory, sinusitis, otitis, meningitis \\
    Bartonella & Small, pleomorphic rods & aerobic/micro\-aerophilic & No & Cats, fleas, lice / cat bites, lice or fleas? & Cat scratch disease, endocarditis, bacillary angiomatosis \\\bottomrule
\end{tabularx}
\end{table}

I also have the following figure:

\begin{figure}[hbt]
\centering
\resizebox{1\textwidth}{!}{\includegraphics{Thesis/Images/Chapters/Chapter 1/A_bacterial_sample_to_a_protein_extraction_and_the_final_analysis_by_mass_spectrometry.jpg}}
\caption{A bacterial sample subjected to a protein extraction and the final analysis by mass spectrometry.}{\cite{Mass_Spectrometry}}
  \label{Fig:Mass Spectrometry}
\end{figure}

These 2 represent the same example I want you to focus. The citation is appearing under the table or figure caption and not in the end of the text of table/figure caption.

If I cite like this: \caption{A bacterial sample subjected to a protein extraction and the final analysis by mass spectrometry. \cite{Mass_Spectrometry}} we will end up with a problem in referencing order cause the list of figures. So we must keep the form \caption{A bacterial sample subjected to a protein extraction and the final analysis by mass spectrometry.}{\cite{Mass_Spectrometry}}. This is also the correct way to do it: \caption[text without cite for the list of figures]{text with cite}

P.S. I do not include the packages used in preamable because I assume they do not matter for this problem. If you want it, just comment it and I will edit.

DGuys
  • 57
  • 4
  • 1
    \caption only has one mandatory argument, I assume you meant \caption[Gram Negative Bacteria.]{\cite{Bacterial_Classification}} not \caption{Gram Negative Bacteria.}{\cite{Bacterial_Classification}} – David Carlisle Nov 30 '23 at 10:37
  • 3
    "P.S. I do not include the packages used in preamable because I assume they do not matter for this problem. " it always helps to provide an example that shows the problem. No one can run these fragments. Don't include all the packages from your real document but make a small complete document that shows the problem. – David Carlisle Nov 30 '23 at 10:39
  • 1
    \resizebox{1\textwidth}{!}{\includegraphics{...}} sounds like a very complicated way to say \includegraphics[width=\textwidth]{...} – samcarter_is_at_topanswers.xyz Nov 30 '23 at 10:40
  • seing as the question is about captions you could also change the text of the figure (to sayABC as currently people need to guess at least booktabs, tabularx and graphicx packages to run these fragments – David Carlisle Nov 30 '23 at 10:40
  • 1
  • You both are correct, I hope every time I post from now on to have a better appearance and more clear informations. @DavidCarlisle As for your first comment... I did meant \caption[text]{\cite{}}, BUT as I see I do not write such a thing.. Is this the mistake causing the problem? I will chek in a minute. – DGuys Nov 30 '23 at 10:43
  • @DavidCarlisle I see, I'm so slow :) – samcarter_is_at_topanswers.xyz Nov 30 '23 at 10:56

1 Answers1

3

\caption only has one mandatory argument, I assume you meant

\caption[Gram Negative Bacteria.]{\cite{Bacterial_Classification}}

not

\caption{Gram Negative Bacteria.}{\cite{Bacterial_Classification}}

David Carlisle
  • 757,742
  • Correct! Once again, you save the day from silly mistakes. – DGuys Nov 30 '23 at 10:51
  • 1
    +1. I think it would be helpful to include some text in the main argument of \caption as well. Thus, \caption[Gram Negative Bacteria.]{Gram Negative Bacteria \cite{Bacterial_Classification}.}. – Mico Nov 30 '23 at 10:57
  • @Mico Thank you, I agree! I did it myselft. In order for it to appear in the list of figures too. – DGuys Nov 30 '23 at 11:06
  • In a long table, how could this be fixed? Because there we have this: caption = {Gram Positive Bacteria.}{\cite{Bacterial_Classification}} and it does not fix if I but [] instead of {}. – DGuys Nov 30 '23 at 11:10
  • Everything works fine in the caption but the cite appears in the list of figures too. – DGuys Nov 30 '23 at 11:11
  • 1
    @DGuys no it won't that is the point of using [...] a version without cite for the list. You have probably not re-run latex. – David Carlisle Nov 30 '23 at 11:12
  • If I run this: \begin{longtblr}[ caption = [Gram Positive Bacteria.]{Gram Positive Bacteria.\cite{Bacterial_Classification}}, it will appear: Table 1.1: [Gram Positive Bacteria.]Gram Positive Bacteria. [1] – DGuys Nov 30 '23 at 11:35
  • both in caption and in the list of figures. – DGuys Nov 30 '23 at 11:35
  • It works with normal tables but not with a longtable. – DGuys Nov 30 '23 at 11:36
  • You could (should?) have mentioned earlier that you employ a longtblr environment. – Mico Nov 30 '23 at 11:38
  • it works with longtable . You are not using longtable but longtblr from a different package you have not mentioned. @DGuys – David Carlisle Nov 30 '23 at 11:53
  • @DGuys check the tabularray documentation, it probably has a key to specify the list of tables entry, just as it has a key to specify the caption – David Carlisle Nov 30 '23 at 11:54
  • I opened the documentation but I can not find it. Could you possibly help me a bit more with this? – DGuys Nov 30 '23 at 12:00
  • @DGuys no sorry it's completely unrelated to the question as posted, and not a package I know that well. – David Carlisle Nov 30 '23 at 12:01