I want to be able to add the source information below figures and tables ( longtables included). I have used the idea provided in this post, but it gives the following error for longtables:
! Misplaced \noalign.
\caption ->\noalign
Is it possible to fix and have a single command that would for those enviroments?
Here is a minimal code to reproduce it.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{longtable,booktabs}
\usepackage{blindtext}
\newcommand{\source}[1]{
\vspace{1ex}\caption*{\textbf{Source:} {#1}}
}
\begin{document}
\begin{table}[h]
\caption{Test - Table}\label{t:test}
\begin{tabular}{p{0.5\textwidth} p{0.5\textwidth}}
\toprule
\blindtext & \blindtext \
\bottomrule
\end{tabular}
\source{Test Test}
\end{table}
\newpage
\begin{longtable}{p{0.5\textwidth} p{0.5\textwidth}}
\caption{Test - Longtable} \label{lt:test} \
\toprule
\blindtext & \blindtext \
\midrule
\blindtext & \blindtext \
\midrule
\blindtext & \blindtext \
\bottomrule
\source{Test longtable 123}
\end{longtable}
\newpage
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{example-image-a}
\caption{Test123.}\label{fig-img-a}
\source{Test image.}
\end{figure}
\end{document}
\multicolumn{2}{@{}l}Source …}as the last row of the table? – Bernard Nov 18 '20 at 14:35\vspace{1ex}and with\\after\source{Test longtable 123}. – Nov 18 '20 at 14:53