在 React 中将 PDF 中的 LaTeX 内容显示为 Markdown 内容时遇到的挑战

在 React 中将 PDF 中的 LaTeX 内容显示为 Markdown 内容时遇到的挑战

我目前正在开展一个项目,将 PDF 文档转换为易于在 Web 界面上编辑和显示的格式,为此我使用标记。它将 PDF 转换为 markdown 并使用 LaTeX 表格。当我尝试使用 React 将解析后的 pdf 显示到网页上时遇到了困难。使用 remarkMath、reactMarkdown 和 reactGfm 等 javascript 库显示 LaTeX 时遇到了困难,它根本不显示,尤其是表格。

据我所知,这完全是乳胶,下面是我试图渲染的乳胶片段:

\begin{table}
\begin{tabular}{l c c c} \hline \hline
**Model** & **ROUGE-L** & **BLEU-1** & **BLEU-4** & **METEOR** \\ \hline BiDAF (Kosisky et al., 2018) & \(6.2\) & \(5.7\) & \(0.3\) & \(3.7\) \\ BM25 + BERT (Mou et al., 2020) & \(15.5\) & \(14.5\) & \(1.4\) & \(5.0\) \\ Recursively Summarizing Books (Wu et al., 2021) & \(21.6\) & \(22.3\) & \(4.2\) & \(10.6\) \\ Retrieval + Reader (Izacard and Grave, 2022) & **32.0** & **35.3** & **7.5** & \(11.1\) \\
**RAPTOR + UnifiedQA** & 30.8 & 23.5 & 6.4 & **19.1** \\ \hline \hline \end{tabular}
\end{table}
Table 6: Performance comparison on the NarrativeQA dataset across multiple models, focusing on four metrics: ROUGE-L, BLEU-1, BLEU-4, and METEOR. RAPTOR, when paired with UnifiedQA 3B, not only surpasses retrieval methods like BM25 and DPR but also sets a new state-of-the-art in the METEOR metric.

\begin{table}
\begin{tabular}{c c c} \hline \hline \multirow{2}{*}{**Model**} & \multicolumn{2}{c}{**Accuracy**} \\ \cline{2-3}  & **Test Set** & **Hard Subset** \\ \hline Longformer-base (Beltagy et al., 2020) & \(39.5\) & \(35.3\) \\ DPR and DeBERTaV3-large (Pang et al., 2022) & \(55.4\) & \(46.1\) \\ CoLISA (DeBERTaV3-large) (Dong et al., 2023) & \(62.3\) & \(54.7\) \\
**RAPTOR + GPT-4** & **82.6** & **76.2** \\ \hline \hline \end{tabular}
\end{table}
**Comparison to State-of-the-art Systems** Building upon our controlled comparisons, we examine RAPTOR's performance relative to other state-of-the-art models. As shown in Table 5, RAPTOR with GPT-4 sets a new benchmark on QASPER, with a 55.7% F-1 score, surpassing the CoLT5 XL's score of 53.9%.

### Contribution of the tree structure

这只是一小段代码,它应该能够呈现大型文档/研究论文。

考虑的解决方案:我考虑在后端使用 pandoc,将我们的 markdown 和 latex 文档转换为可读的内容,然后获取它并在前端显示。我也曾考虑过使用 Python 库来转换它,但发现它们可能与 LaTeX 不完全兼容。我也尝试过使用 JavaScript 库,如 react-Markdown、remarkGfm 和 remarkMath,但这些都无法输出 LaTeX 表格。

问题:如果有人以前处理过类似的事情,你会建议我做什么?是否有我可能错过的更好的方法或库(JavaScript 或 Python)?Pandoc 会将 markdown 和 latex 转换为什么?

非常感谢!任何反馈都非常好。

目前的方法:我尝试使用 javascript 库,如 remarkMath、rehypeKatex、reactMarkdown 和 reactGfm。markdown 转换器运行良好,但当它转换到 LaTeXtables 时,它根本无法转换。我希望对如何做到这一点有所了解。

相关内容