wengan-li / ncku-thesis-template-latex

NCKU Thesis/Dissertation Template in Latex | 台灣國立成功大學碩博士用畢業論文LaTex模板
Other
92 stars 40 forks source link

``\InsertFigure`` does not allow `\cite` in caption. #66

Open Nana2929 opened 1 week ago

Nana2929 commented 1 week ago

Description

I'd like to cite something inside a figure's caption. Latex naturally supports it with \includegraphics command (as in second example), but \InsertFigure (in this template) will show red compilation errors (as the first example). My latex compiler is XeLatex 2023 (provided by Overleaf). This also leads me to wonder if we must use \InsertFigure, since using \includegraphics seems to display as well, and the figure appears on List of Figure section as expected.

% does not work
\InsertFigure[scale=0.5,caption={The four key elements in the expected output sentiment tuple of ABSA (\cite{Zhang2023ABSASurvey}},label={fig:absa}] 
{context/related-work/images/keys-in-absa.png}

% works
\begin{figure}[h]
    \centering
    \includegraphics[scale=0.5]{context/related-work/images/keys-in-absa.png}
    \caption{The four key elements in the expected output sentiment tuple of ABSA (\cite{Zhang2023ABSASurvey})}
    \label{fig:keys-in-absa}
\end{figure}

Error Messages

截圖 2024-07-02 下午5 05 49

wengan-li commented 1 week ago

Hello @Nana2929,

Have you tried \RefTo{} ?

Sometimes, the helper commands do not work with some Latex syntax, as I mention in Objective:

    某些包裝出來的語法, 可能會在一些情況下會產生衝突而令LaTex不接受, 這時候有2種做法:
    \begin{enumerate}
      \item
      {
        不使用某些寫法, 例如已知的`\verb|\InsertFigure|'沒法被包在Table, minipage或framebox中.
      } % End of \item{}

      \item
      {
        如真的要使用那些情況, 那就不要使用模版提供的語法, 而直接去寫LaTex原版的語法.
      } % End of \item{}
    \end{enumerate}

In your case, I think you need to use figure block to bypass.

\begin{figure}[h]
  ...
\end{figure}