
我使用 skak 生成了一本精美的 PDF 格式的國際象棋書籍。不幸的是,Amazon Kindle 不能很好地匯入 PDF。所以,我必須製作一本 Kindle 友善的格式書籍,例如 epub。
是否可以使用相同的latex來源文件來產生epub?如果沒有,是否有其他乳膠包可以幫助生成國際象棋書籍的 epub 文件?
這是最小的範例文件:
\documentclass[a4paper,11pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=[RGB]{41,41,41},
filecolor=magenta,
urlcolor=cyan,
pdftitle={Chess},
bookmarks=true,
}
\usepackage[ps]{skak}
\showmoverOn
\begin{document}
\frontmatter
\title{My title}
\maketitle
\tableofcontents
\mainmatter
\author{Sudheer}
\chapter{Introduction}
\newgame
\mainline{1.e4 c5 2.Nf3 g6 3.Bc4 Bg7 4.Ng5 e6}
\showboard
\end{document}
我正在使用以下步驟進行編譯:
latex minimum.tex
dvips minimum.dvi
ps2pdf minimum.ps
答案1
您可以使用tex4ebook
它來創建ePub
或mobi
電子書。它用於tex4ht
轉換。tex4ht
不支援skak
開箱即用的包,但它很容易配置,因此我們可以自己添加支援。
有兩件事需要解決:文本中的棋子和棋盤。棋子可以轉換為Unicode字符,棋盤必須轉換為圖像。
圖形使用特殊字體,需要在tex4ht
.將以下文字儲存為SkakNew.htf
並將其放入文件所在的目錄中:
SkakNew 32 121
'' '' 32
'!' '' 33
'”' '' 34
'#' '' 35
'$' '' 36
'%' '' 37
'&' '' 38
'’' '' 39
'(' '' 40
')' '' 41
'*' '' 42
'+' '' 43
',' '' 44
'-' '' 45
'.' '' 46
'/' '' 47
'0' '' 48
'1' '' 49
'2' '' 50
'3' '' 51
'4' '' 52
'5' '' 53
'6' '' 54
'7' '' 55
'8' '' 56
'9' '' 57
':' '' 58
';' '' 59
'¡' '' 60
'=' '' 61
'¿' '' 62
'?' '' 63
'@' '' 64
'→' '' 65
'♗' '' 66
'↑' '' 67
'⊙' '' 68
'△' '' 69
'□' '' 70
'⇗' '' 71
'⇔' '' 72
'⊞' '' 73
'╳' '' 74
'♔' '' 75
'⟂' '' 76
'≪' '' 77
'♘' '' 78
'≫' '' 79
'Ⅱ' '' 80
'♕' '' 81
'♖' '' 82
'>' '' 83
'⊕' '' 84
'○' '' 85
'⇆' '' 86
'W' '' 87
'×' '' 88
'Y' '' 89
'Z' '' 90
'[' '' 91
'“' '' 92
']' '' 93
'ˆ' '' 94
'˙' '' 95
'‘' '' 96
'⧉' '' 97
'⌓' '' 98
'±' '' 99
'⦂' '' 100
'∓' '' 101
'⩲' '' 102
'⩱' '' 103
'h' '' I cannot find it, it is plus followed by minus
'i' '' minus followed by plus
'=' '' 106
'k' '' 107
'l' '' 108
'#' '' 109
'n' '' 110
'o' '' 111
'p' '' 112
'q' '' 113
'r' '' 114
's' '' 115
't' '' 116
'u' '' 117
'v' '' 118
'w' '' 119
'x' '' 120
'y' '' 121
SkakNew 32 121
可以透過以下配置請求棋盤圖像。將其另存為skak.4ht
並將其儲存到文件的目錄中:
\NewConfigure{SkakBoard}{2}
\pend:def\showboard{\a:SkakBoard}
\append:def\showboard{\b:SkakBoard}
\Configure{SkakBoard}{\Picture+{}}{\EndPicture}
\endinput
它只是修補命令\showboard
以包含tex4ht
將包含的內容轉換為圖像的特殊命令。
mobi
您可以使用以下命令來編譯文件。請注意,您需要kindlegen
安裝:
tex4ebook -f mobi minimum.tex
結果如下,以 Calibre 所示:
為了獲得更好的圖像質量,您可以嘗試將以下行添加到文件中skak.4ht
(在 之前\endinput
):
\Configure{Picture}{.svg}
它將請求以下svg
格式的圖形:
最後一點:我得到了無效ePub
文件,因為你使用了\author
after maketitle
,你應該把它放在它之前。
編輯:
如果您想使用更多列印到一張畫布的命令,您需要將它們包含在自訂環境中,其內容將轉換為圖像:
\documentclass[a4paper,11pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=[RGB]{41,41,41},
filecolor=magenta,
urlcolor=cyan,
pdftitle={Chess},
bookmarks=true,
}
\usepackage[ps]{skak}
\showmoverOn
\newenvironment{mymoves}{}{}
\begin{document}
\frontmatter
\title{My title}
\author{Sudheer}
\maketitle
\tableofcontents
\mainmatter
\chapter{Introduction}
\newgame
\mainline{1.e4 c5 2.Nf3 g6 3.Bc4 Bg7 4.Ng5 e6}
\begin{mymoves}
\showboard
\printarrow{a1}{a8}
\end{mymoves}
\end{document}
這裡重要的部分是:
\begin{mymoves}
\showboard
\printarrow{a1}{a8}
\end{mymoves}
您可以mymoves
在設定檔中設定環境:
\Preamble{xhtml}
\Configure{Picture}{.svg}
\ConfigureEnv{mymoves}{\Picture*{}}{\EndPicture}{}{}
\begin{document}
\EndPreamble
注意,這個範例似乎需要使用SVG輸出,似乎dvipng
不支援某些PostScript。
結果: