lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
911 stars 72 forks source link

Latex to docx cannot generate table number #372

Open rohachen opened 1 year ago

rohachen commented 1 year ago

Im using pandoc-crossref v0.3.14.0 pandoc-2.19.2 my command is:

pandoc -F  pandoc-crossref -F pandoc-tablenos -M chapters -s testbook.tex  -f latex  -t docx --toc --toc-depth=4 --top-level-division=chapter  --default-image-extension ".png" --reference-doc=test_ref.docx  --metadata-file=metadata.yaml  -o output2.docx

it can generate figure num correctly. but table num is empty

metadata like this:

---
numbersections: true
subparagraph: yes
# Filter preferences:
# - pandoc-crossref
numberSections: true
linkReferences: true
toc: true
lot: true
lof: true
toc-title: "Contents"
chapter: true
chaptersDepth: 1 
sectionsDepth: 0 
setLabelAttribute: true
secHeaderDelim: " "
tableTitle: "Table:"
figureTitle: "Figure"
#titleDelim: " "
---

what's wrong with my code?

K4zuki commented 1 year ago

Does it change if swapping order of the filter applies? i.e. pandoc -F pandoc-tablenos -F pandoc-crossref ... ?

rohachen commented 1 year ago

Does it change if swapping order of the filter applies? i.e. pandoc -F pandoc-tablenos -F pandoc-crossref ... ?

I tried it, but it's no different ...

lierdakil commented 1 year ago

You're using LaTeX as input format. This is not directly supported, but see #250

lierdakil commented 1 year ago

Tables should be, broadly speaking, recognized by Pandoc, but latex is a zoo with a circus, so the particular way you have your tables setup might not be recognized :shrug:

lierdakil commented 1 year ago

Also, why are you running pandoc-tablenos and pandoc-crossref together? What are you trying to achieve here, exactly?

rohachen commented 1 year ago

Also, why are you running pandoc-tablenos and pandoc-crossref together? What are you trying to achieve here, exactly?

Emm, this problem has troubled me for a long time, I want to number figures and tables with chapter like Figure 2-1, Table 2-1 ... so I tried different methods,but had no effect . pandoc-tablenos is also an invalid experiment.

I use longtable in my tex proj:

\newcommand{\BeginLongTable} [3] 
{
    \begin{center}
    \begin{footnotesize}
    \begin{longtable}{#2}
    \caption{#1} \label{tbl:#1} \\
    \hline
    \rowcolor{gray50} #3 \\
    \hline
    \endhead
    \hline
    \endfoot
    \endlastfoot
}

\newcommand{\EndLongTable}
{
    \end{longtable}
    \end{footnotesize}
    \end{center}
}

everything else is good except that there is no table number ...

But thinks to pandoc-crossref,figure number is correct.

maybe I should edit table caption in document.xml? I don't think it's a good way

rohachen commented 1 year ago

I was making the elementary mistak. the first few tables in my tex is:

\begin{table}[htbp]
  \centering
  \begin{tabular}[c]{|l|l|}
  \hline
  \rowcolor{lightgray}  Option & Action \\
  \hline
    a  & c \\
  \hline
    b & d \\
  \hline
  \end{tabular}
    \caption{command line option} \label{tbl:command line option}
\end{table}

and all my longtable performed normally. Now my job is to modify these.

btw:

lot: true
lof: true

seems to have no effect,Maybe it should rely on the docx template?

thanks a lot

lierdakil commented 1 year ago
lot: true
lof: true

:confused: these are not pandoc-crossref options. If you want list-of-figures etc, use \listoffigures in the source document and use latex+raw_tex as the input format.