导图社区 如何制作一个简单的epub电子书
想要简单的制作epub,但却不知从何下手,从零精学的话太浪费时间。那就不如来此简单的学习一下。
编辑于2022-07-22 12:18:12如何制作一个简单的epub电子书
前言:某一个闲来无事的假日,本人突然想要制作一个简单的epub电子书,因此去寻找和借鉴了很多资料,用Sigil制作的,最终算是勉强成功。想着摸索出的方法与其自己存着,不如分享一下。
注:代码太多,影响整体观感,因此就展示了前面小部分。有兴趣制作epub的伙伴,可以试下已展开的代码,如果觉得不错,就使用这个模板吧。
为便于理解,代码中的加粗的文字中的内容为需要更替的部分或注释(打开Sigil,复制代码到相应板块即可。)
由于是个人整理制作,因此不一定是最佳方案,不喜勿喷,望谅解。
0、实用技巧
1、文本
利用text文件时,可利用excel的函数&实现批量添加<p>和</p>(即文本换行符号)
2、关于网上图片无法下载的措施
利用360浏览器,按F12开启浏览器,点击源文件,查看文件中的images,在新的窗口打开,进行另存为即可
或图片-右键-审查元素-找到图片-在新的窗口打开-另存为
3、所有的都是有规律的,要注重模板里的代码作用和其规律。
一、关于Txt文本
1.cover01,02,封面及封底
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>封面</title> </head> <body> <!--警告:这里的代码不要做任何改动!--> <!--书名在title.xhtml中填写--> <div class="cover"><img alt="" class="bb" src="../Images/cover01.jpg"/></div><!--封面图片--> </body> </html>
2.title,书本基础信息
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--><head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>标题</title> </head> <body> <div> <!--标题样式自助--> <div class="title3"> 填入书本名称 </div> <div> <h3 class="center la bold"><span class="em13 bold co6"><span class="bo4"> 填入书本副标题</span> </span></h3> </div> <div class="center"> <span class="em12">其他内容</span> <span class="em12">其他内容</span> </div> </div> </body> </html>
3.message,epub制作组信息
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>制作信息</title> </head> <body> <div> <p class="meg">制作信息</p> <div><br/></div><hr/><!--分隔线--> <div><br/></div> <p class="message">书名:</p> <div><br/></div> <p class="message">作者:</p> <div><br/></div> <p class="message">插画:</p> <div><br/></div> <p class="message">翻译:</p> <div><br/></div> <p class="message">校对:</p> <div><br/></div> <p class="message">文字来源:/p> <div><br/></div> <p class="message">插图来源:</p> <div><br/></div> <p class="message">仅供学习交流使用,禁止商业用途</p> <div><br/></div> <p class="message">下载后请在24小时内删除</p> <div><br/></div> <p class="message">请尊重翻译、扫图、录入、校对的辛勤劳动,转载请保留信息</p> <div><br/></div> <div><br/></div><hr/><!--分隔线--> </div> </body> </html>
4.logo,epub制作组logo
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>制作者与Logo</title> </head> <body> <div> <div class="logo-img"><img alt="" class="logo-width" src="../Images/logo.jpg"/></div> <div> <dl class="logo-maker"> <dt><span class="logo-font">制作者</span></dt> <dd><span class="logo-font">Pub制作组制作者id</span></dd> </dl> </div> </div><!--如果需要,添加下列代码(在</dl>内)并填写信息 <dt>援助者</dt> <dd>模板</dd> --> </body> </html>
5.summary,内容简介
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>内容简介</title><!--填入章节名--> </head> <body> <div> <!--这个div不要改动--> <h4>内容简介</h4> <hr/> <p class="em12 co6">历经曲折,<span class="em13 bold co6">安艺伦也</span>的<span class="em13 bold co6">游戏制作</span>社团起步了。他做为一名<span class="em13 bold co6">创作人</span>的<span class="em13 bold co6">光荣日子</span>也<span class="em13 bold co6">终于开始了?</span></p> <p><br/></p> </div> </body> </html>
6.illus1和illus1-1,开头插画及图中文字翻译
插画: <?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>彩页</title><!--填入章节名--> </head> <body> <div> <!--这个div不要改动--> <div class="illus"><img alt="illus02" src="../Images/illus02.jpg"/></div> </div> </body> </html> 文字: <?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>彩页</title><!--填入章节名--> </head> <body> <div> <!--这个div不要改动--> <div class="co5"> <p class="em14 zin bold">「哎呀~~</p> </div> </div> </body> </html>
7.contents,有跳转功能的目录
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>目录</title> </head> <body> <div> <h4 class="left"><span class="bo4">Contents</span></h4> </div> <div class="em09"> <p class="zin"><a class="no-d" href="../Text/Section001.xhtml"><span class="co9">序章</span></a></p> <p class="zin"><a class="no-d" href="../Text/Section002.xhtml"><span class="co9">第一章 </span></a></p> <p class="zin"><a class="no-d" href="../Text/Section003.xhtml"><span class="co9">第二章 </span></a></p> <p class="zin"><a class="no-d" href="../Text/Section004.xhtml"><span class="co9">第三章 </span></a></p> <p class="zin"><a class="no-d" href="../Text/Section010.xhtml"><span class="co9">后 记</span></a></p> <p class="zin"><a class="no-d" href="../Text/Section011.xhtml"><span class="co9">参考资料</span></a></p> </div> </body> </html>
8.section
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <!--(xml:lang="zh-CN")这句拆分时不要弄丢--> <head> <link href="../Styles/style.css" rel="stylesheet" type="text/css"/> <title>序章</title><!--填入章节名--> </head> <body> <div> <!--这个div不要改动--> <h4>序章</h4>(填入章节名) <p>正文</p>(填入正文) <p><br/></p>(插入空白行) <div class="illus"><img alt="img001" src="../Images/img001.jpg"/></div>(插入插画) <p>文本<span class="postil-b">①</span>文本</p>(引用注释) <p class="postil-od">注①:</p>(注释) </div> </body> </html>
二、关于Styles
style,文本特效等(可以找其他epub中的直接复制过来,也可复制这里的代码,然后修改特效代码即可)
/*所有自定义css内容写最下方*/ body { padding: 0%; margin-top: 0%; margin-bottom: 0%; margin-left: 1%; margin-right: 1%; line-height: 130%; text-align: justify; } h1 { line-height: 130%; text-align: center; font-weight: bold; font-size: xxx-large; margin-top: 0.2em; margin-bottom: 0.3em; } h2 { line-height: 130%; text-align: center; font-weight: bold; font-size: x-large; margin-top: 0.2em; margin-bottom: 0.3em; } h2.subtitle { font-size: 20px; } h3 { font-size: large; line-height: 130%; text-align: center; text-indent: 0em; font-weight: bold; margin-top: 0.2em; margin-bottom: 0.2em; } h4 { font-size: 1.5em; text-align: center; line-height: 1.2em; text-indent: 0em; font-weight: bold; margin-top: 1em; margin-bottom: 1.5em; } div { margin: 0px; padding: 0px; text-align: justify; } p { text-indent: 2em; display: block; line-height: 1.3em; margin-top: 0.4em; margin-bottom: 0.4em; } ul.contents { text-indent: 0em; font-size: 1.06em; font-weight: bold; } li.c-rules { margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.1em; } li ul li.c-rules { font-size: 15px; margin-left: -1em; line-height: 1.1em; font-weight: normal; } .bb { border-style: none solid none solid; border-color: #000000; border-width: 1px; } .biaoti { font-size: 1.5em; text-indent: 0em; font-weight: bold; text-align: center; margin-top: 0.2em; margin-bottom: 0.2em; } .biaoti-left { font-size: 1.3em; text-indent: 0em; font-weight: bold; margin-top: 0.5em; margin-bottom: 0.5em; } .caiye { text-indent: 0em; font-size:1.2em; font-weight:bold; } .cont { text-indent: 2em; font-size: 1.2em; font-weight: bold; } .logo-img { text-indent: 0em; text-align: center; margin-top: 30%; margin-bottom: 0%; } .logo-maker { border-bottom-style: solid; border-color: #000000; border-width: 0.1em; font-size: 1.1em; font-weight: bold; text-indent: 0em; text-align: right; margin: 0% 2% 0% 32%; padding-right: 6%; } dl.logo-maker > dt { font-size: 15px; } .logo-width { width:100%; } .cut-line { text-indent: 0em; line-height: 0%; margin-top: 0.3em; margin-bottom: 0.3em; } .cover { margin: 0; padding: 0px; text-indent: 0; text-align: center; } .dash-break { word-break:break-all; word-wrap:break-word; } .illus { text-indent: 0; text-align: center; } .left { text-indent: 0em; text-align: left; } .line-index { width: 50%; text-align: left; margin-left: 1em; } .message { text-indent: 0em; line-height: 1.2em; margin-top: 0.2em; margin-bottom: 0.2em; } .meg { font-size: 1.3em; text-indent: 0em; font-weight: bold; margin-top: 0.5em; margin-bottom: 0.5em; } .right { text-align: right; } .stress { font-weight: bold; font-size: 1.1em; margin-top: 0.3em; margin-bottom: 0.3em; } .title-main { border-style: ridge groove none none; border-color: #000000; border-width: 6px; margin: 12px; padding: 8px; } .zuozhe { font-size:1.2em; text-align:right; font-weight:bold; font-style:italic; margin-right: 1em; } .postil-b { font-size: 0.8em; vertical-align: super; font-weight: bold; color: #898686; } .postil-od { font-size: 0.7em; text-indent: -0.8em; line-height: 120%; color: #000000; padding: 0em 0.2em 0.2em 1em; margin: 0.6em 1% 1em 2.9em; border-style: dotted; border-color: #898686; border-width: 1px; } /*所有自定义css内容写该线下方*/ .logo-font{ text-shadow: 1px 1px 7px #000000; } .zin{ text-indent: 0em; } .bold{ font-weight:bold; } .center{ text-align: center; } .em07{ font-size:0.7em; } .em08{ font-size:0.8em; } .em09{ font-size:0.9em; } .em11{ font-size:1.1em; } .em12{ font-size:1.2em; } .em13{ font-size:1.3em; } .em14{ font-size:1.4em; } .em15{ font-size:1.5em; } .mululu{ text-indent:0em; text-align: center; padding:0.3em; } .no-d{ text-decoration: none; } td { vertical-align: top; text-align: right; } th { width: 100%; vertical-align: top; text-align: right; } .ct1{ border-collapse:collapse; } .brb1{ border-right: 4px solid #000000; border-bottom: 4px solid #000000; } .brt1{ border-right: 4px solid #000000; border-top: 4px solid #000000; } .brl1{ border-right: 4px solid #000000; border-left: 4px solid #000000; } .br1{ border-right: 4px solid #000000; } .bt1{ border-top: 4px solid #000000; } .f1{ font-size: 2em; margin-right: 0.2em; } .f2{ margin-right: 0.3em; } .border{ border:2px #F9B904 solid; border-radius:50%; padding:1em 1em 1em 1em; margin:2% 0 0 2%; box-shadow: 0px 0.5px 0.5px 3px #D3D3CE; } .border1{ border:2px #4381B2 solid; border-radius:50%; padding:1.5em 1.2em 1.5em 1.2em; margin:2% 0 0 2%; box-shadow: 0px 0.5px 0.5px 3px #D3D3CE; } .border2{ border:2px #DE2E6F solid; border-radius:50%; padding:0.5em 1em 0.5em 1em; margin:2% 0 0 2%; box-shadow: 0px 0.5px 0.5px 3px #D3D3CE; } .border3{ border:2px #24C995 solid; border-radius:50%; padding:1em 1.2em 1em 1.2em; margin:2% 0 0 2%; box-shadow: 0px 0.5px 0.5px 3px #D3D3CE; } .co1{ color:#FCB706; } .co2{ color:#4381B2; } .co3{ color:#DE2E6F; } .co4{ color:#21B286; } .co5{ color:#FFFFFF; text-shadow:0px 0px 4px #DE2E6F; } .co6{ color:#F2280D; } .co9{ color:#000000; } .yin{ color:#FFFFFF; text-shadow:0px 0px 4px #FCB706; font-size:1.1em; font-weight:bold; } .yin2{ color:#FFFFFF; text-shadow:0px 0px 4px #4381B2; font-size:1.1em; font-weight:bold; } .yin3{ color:#FFFFFF; text-shadow:0px 0px 4px #DE2E6F; font-size:1.1em; font-weight:bold; } .yin4{ color:#FFFFFF; text-shadow:0px 0px 4px #21B286; font-size:1.1em; font-weight:bold; } .bo{ height:5em; width:6em; } .title3{ font-size: 1.5em; text-indent:0em; font-weight: 900; text-align: center; margin-top: 25%; margin-bottom: 10PX; color: #F2280D; } .bo2{ text-align:center; text-indent:0em; border:1px #317EC9 solid; color:#FFFFFF; background-color:#317EC9; border-radius:50%; font-size: 1.5em; padding:0px 5px 0px 5px; } .la{ margin-top: 5%; margin-bottom: 30PX; } .bo3{ border:1px #000000 solid; } .bo4{ border: solid 3px #000000; padding:0.4em 0.2em; border-radius: 40px; margin-top:5%; font-size:1.1em; } .bo5{ border-style: none none solid none; border-color: #020202; border-width: 1px; margin:1em 0em 0em 0em; padding:0px 2px; width:19em; } .bo7{ border-style: none none solid none; border-color: #020202; border-width: 1px; margin:1em 0em 0em 0em; padding:0px 2px; width:5em; } .bo8{ border-style: none none solid none; border-color: #020202; border-width: 1px; margin:1em 0em 0em 0em; padding:0px 2px; width:12em; } .bo9{ border-style: none none solid none; border-color: #020202; border-width: 1px; margin:1em 0em 0em 0em; padding:0px 2px; width:10em; } .bo10{ border-style: none none solid none; border-color: #020202; border-width: 1px; margin:1em 0em 0em 0em; padding:0px 2px; width:9em; } .bo11{ border-style: none none solid none; border-color: #020202; border-width: 1px; margin:1em 0em 0em 0em; padding:0px 2px; width:7em; }
三、关于Images
0.无要求,命名恰当即可
常用命名
cover01,02——封面封底
illus01,02等——卷头插画
img001,002等——正文插画
logo——制作组logo
四、关于content.opf
content.opf,是在在阅读软件显示的epub制作信息
<?xml version="1.0" encoding="utf-8"?> <package version="2.0" unique-identifier="BookId" xmlns="http://www.idpf.org/2007/opf"> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> <dc:identifier id="BookId" opf:scheme="UUID">urn:uuid:5208e6bb-5d25-45b0-a7fd-b97d79a85fd4</dc:identifier> <dc:title>书名</dc:title> <dc:creator opf:file-as="epub制作者" opf:role="aut">作者</dc:creator> <dc:language>zh</dc:language> <dc:subject>书的类型</dc:subject> <dc:description>epub制作者</dc:description> <dc:publisher>epub制作者</dc:publisher> <dc:date opf:event="modification">2022-07-18</dc:date> <meta content="1.2.0" name="Sigil version" /> </metadata> <manifest> <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/> <item id="cover01.xhtml" href="Text/cover01.xhtml" media-type="application/xhtml+xml"/> <item id="title.xhtml" href="Text/title.xhtml" media-type="application/xhtml+xml"/> <item id="Section0001.xhtml" href="Text/Section0001.xhtml" media-type="application/xhtml+xml"/> <item id="style.css" href="Styles/style.css" media-type="text/css"/> <item id="Illus1.xhtml" href="Text/Illus1.xhtml" media-type="application/xhtml+xml"/> <item id="Section001.xhtml" href="Text/Section001.xhtml" media-type="application/xhtml+xml"/> <item id="cover2.xhtml" href="Text/cover2.xhtml" media-type="application/xhtml+xml"/> <item id="cover.jpg" href="Images/cover.jpg" media-type="image/jpeg"/> <item id="image-0001.jpeg" href="Images/image-0001.jpeg" media-type="image/jpeg"/> <item id="image-0002.jpeg" href="Images/image-0002.jpeg" media-type="image/jpeg"/> <item id="image-0003.jpeg" href="Images/image-0003.jpeg" media-type="image/jpeg"/> <item id="image-0004.jpeg" href="Images/image-0004.jpeg" media-type="image/jpeg"/> <item id="image-0005.jpeg" href="Images/image-0005.jpeg" media-type="image/jpeg"/> <item id="message.xhtml" href="Text/message.xhtml" media-type="application/xhtml+xml"/> </manifest> <spine toc="ncx"> <itemref idref="cover01.xhtml"/> <itemref idref="title.xhtml"/> <itemref idref="message.xhtml"/> <itemref idref="Illus1.xhtml"/> <itemref idref="Section001.xhtml"/> <itemref idref="Section0001.xhtml"/> <itemref idref="cover2.xhtml"/> </spine> <guide> <reference type="cover" title="Cover" href="Text/cover01.xhtml"/> </guide> </package>
五、关于toc.ncx
toc.ncx,即是索引跳转页
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> <head> <meta content="urn:uuid:5208e6bb-5d25-45b0-a7fd-b97d79a85fd4" name="dtb:uid"/> <meta content="0" name="dtb:depth"/> <meta content="0" name="dtb:totalPageCount"/> <meta content="0" name="dtb:maxPageNumber"/> </head> <docTitle> <text>书名</text> </docTitle> <docAuthor> <text>作者</text> </docAuthor> <navMap> <!--一对navPoint标签代表一个章节,按需要设定(字母区分大小写)--> <navPoint id="cover" playOrder="0"><!--模板中设置好的前三章请不要改动--> <navLabel> <text>封面</text> </navLabel> <content src="Text/cover.xhtml"/> </navPoint> <navPoint id="message" playOrder="1"> <navLabel> <text>制作信息</text> </navLabel> <content src="Text/message.xhtml"/> </navPoint> <navPoint id="contents" playOrder="2"><!--章节的ID、播放顺序--> <navLabel> <text>目录</text> </navLabel> <content src="Text/contents.xhtml"/> </navPoint> <navPoint id="summary" playOrder="3"><!--ID是该章节的文件名,播放顺序按照章节顺序修改--> <navLabel> <text>内容简介</text><!--填写章节的名称--> </navLabel> <content src="Text/Summary.xhtml"/><!--修改为需要链接到的章节文件名--> </navPoint> <navPoint id="illus1" playOrder="4"> <navLabel> <text>彩页</text> </navLabel> <content src="Text/Illus1.xhtml"/> </navPoint> <navPoint id="section001" playOrder="5"> <navLabel> <text>序 章</text> </navLabel> <content src="Text/Section001.xhtml"/> </navPoint> <navPoint id="section002" playOrder="6"> <navLabel> <text>第一章 </text> </navLabel> <content src="Text/Section002.xhtml"/> </navPoint> <navPoint id="section003" playOrder="7"> <navLabel> <text>第二章 </text> </navLabel> <content src="Text/Section003.xhtml"/> </navPoint> <navPoint id="section004" playOrder="8"> <navLabel> <text>第三章 </text> </navLabel> <content src="Text/Section004.xhtml"/> </navPoint> <navPoint id="section05" playOrder="9"> <navLabel> <text>后 记</text> </navLabel> <content src="Text/Section06.xhtml"/> </navPoint> <!--章节不够的话,自己复制粘贴一段代码--> <navPoint id="section07" playOrder="10"> <navLabel> <text>参考资料</text> </navLabel> <content src="Text/Section08.xhtml"/> </navPoint> <navPoint id="section09" playOrder="11"> <navLabel> <text>封底</text> </navLabel> <content src="Text/Section10.xhtml"/> </navPoint> </navMap> </ncx>