超引用包含文件

超引用包含文件

我有一个 latex 文件,希望将其转换为 html 文档。它由许多子文件和一个主文档组成。我想像 wiki 一样将这些文件(included/master-file)的不同部分/节相互链接。

答案1

您可以使用命令行选项将章节或部分放入独立页面。可以使用包\nameref提供的命令添加超链接Hyperref。它基于标准标签/引用机制。

您没有提供任何示例,因此这是我的 MWE sample.tex

\documentclass{book}
\usepackage{lipsum}
\usepackage{hyperref}
\title{Site title}
\author{Neutrino}
\begin{document}
\maketitle

\input{hello-world}
\input{another-section}

\end{document}

它包括两个文件hello-world.tex

\chapter{Hello world}
\label{chap:hello-world}
\lipsum

第二个文件名为another-section.tex

\chapter{Another section}
\label{chap:another-section}

We can try to link to chapter~\nameref{chap:hello-world}.

\lipsum

您可以\nameref在此处查看命令的使用。

使用以下命令编译该文档:

make4ht sample.tex "2,sec-filename"

文件名后面的选项要求将章节剪切为独立的 HTML 文件。生成的文件的名称将基于章节标题。使用选项可启用此功能sec-filename

sample.html包含标题和目录:

在此处输入图片描述

该文件Anothersection.html包含该章节的链接Hello world

在此处输入图片描述

相关内容