Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.09k stars 959 forks source link

`figureTitle` and `tableTitle` seemingly ignored in XeLaTeX builds #256

Open thomasWeise opened 2 years ago

thomasWeise commented 2 years ago

I am sorry to disturb your work. First of all, let me thank you for publishing the very nice eisvogel.tex template, which I am using very happily.

It seems that figureTitle and tableTitle may be ignored under XeLaTeX builds. I have two builds, one in German and one in Chinese. For both, figureTitle and tableTitle work completely fine when rendering to HTML, so it does not seem to be a core pandoc issue. When building to pdf using the eisvogel.tex template, I have to select the XeLaTeX pipeline for the Chinese version while using the default engine for the German one. The German version renders completely fine and produces a pdf where the figure and table captions contain the German words. The Chinese version, however, produces a pdf where the figure and table captions are the English terms "Figure" and "Table", respectively.

Maybe I am doing something wrong here?

I have attached for you an archive with all three cases discussed above (xelatex + eisvogel: does not use proper figure caption, latex + eisvogel: uses proper figure captions, xelatex without eisvolge: uses proper figure caption):

problem_with_xelatex_and_captions.zip

(Side note: If figureTitle and tableTitle actually do not work, maybe listingTitle probably won't work either, but I did not test that yet.)

Many thanks for your help. Thomas.

P.S.:

I first thought that this was an issue with pandoc-crossref, but it seems not to be the case, as the figure captions work well if I do not use eisvogel.tex.

ajeep8 commented 2 years ago

@thomasWeise I meet the same problem with you, did you solve it ?

thomasWeise commented 2 years ago

Hi. Sorry, I do not know how to solve it :-( If you find a solution, please post it here ... because I don't know why it doesn't work

supcik commented 2 years ago

Can you try to replace the figureTitle entry with this header-includes in the metadata :

header-includes:
- |
  ```{=latex}
  \AtBeginDocument{%
  \addto\captionsenglish{\renewcommand{\figurename}{图}}
  }
  ```

So your "book.md" should look like this :

---
CJKmainfont: Noto Sans CJK SC
header-includes:
- |
  ```{=latex}
  \AtBeginDocument{%
  \addto\captionsenglish{\renewcommand{\figurename}{图}}
  }
  ```
...

![Somefigure](fig.png){#fig:fig}

@fig:fig
ajeep8 commented 2 years ago

\AtBeginDocument{% \addto\captionsenglish{\renewcommand{\figurename}{图}} }

Thank you very much, it work. I add the code into templates file directly.

thomasWeise commented 2 years ago

Great! It also works for me. To fix the same issue also for tables, I do

\AtBeginDocument{%
  \addto\captionsenglish{\renewcommand{\figurename}{图}}%
  \addto\captionsenglish{\renewcommand{\tablename}{表}}% 
  }%  

This workaround solves the problem.

ajeep8 commented 2 years ago

This will work as metadata define:

\AtBeginDocument{%
 \addto\captionsenglish{\renewcommand{\figurename}{$figureTitle$}}
\addto\captionsenglish{\renewcommand{\tablename}{$tableTitle$}}
}