Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"title" tag is empty (epubcheck doesn't like it for epub3) #70

Closed
DavidGriffith opened this issue Jun 20, 2020 · 15 comments
Closed

"title" tag is empty (epubcheck doesn't like it for epub3) #70

DavidGriffith opened this issue Jun 20, 2020 · 15 comments

Comments

@DavidGriffith
Copy link

At the top of bookname-epub/OEBPS/bookname.html is this text:

<?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"  
> 
<head> <title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<!-- charset=utf-8,epub,uni-html4,html,xhtml --> 
<meta name="src" content="bookname.tex" /> 
<link rel="stylesheet" type="text/css" href="bookname.css" /> 
</head><body
>

Note this text: <title></title>. epubcheck doesn't complain about this for epub2 files.

Here's the top of the equivalent file for epub3 in ``bookname-epub3/OEBPS/bookname.xhtml`.

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="en-US"> 
<head> <title></title> 
<meta charset="UTF-8" /> 
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" /> 
<link rel="stylesheet" type="text/css" href="bookname.css" /> 
</head><body 
>

How can I insert something meaningful in that <title></title> environment?

@DavidGriffith DavidGriffith changed the title Element "title" must not be empty (for epub3) "title" tag is empty (epubcheck doesn't like it for epub3) Jun 20, 2020
@michal-h21
Copy link
Owner

<title> element normally contains contents of the \title command. But it is saved only when you use the \maketitle, otherwise it isn't available to TeX4ht.

You can also use \Configure{@TITLE}{My title} in the .cfg file, but this will not update the book metadata. You need also another configuration in this case:

\Preamble{xhtml}
\Configure{@TITLE}{My title}
\Configure{SafeTitle}{My title}
\begin{document}
\EndPreamble

But it is still best to use \title ... \maketitle combo, as it will take care of everything.

@DavidGriffith
Copy link
Author

I was using an SVG file as the title page. When I tried to use the titlepage environment to customize the output of \maketitle, I got this:

tex4ebook -xs -f epub3 -c foo.cfg foo.tex
[STATUS]  tex4ebook: Conversion started
[STATUS]  tex4ebook: Input file: foo.tex
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ?    221      LaTeX Error: Environment titlepage undefined.
[ERROR]   htlatex: ?    233      LaTeX Error: Missing \begin{document}.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ?    221      LaTeX Error: Environment titlepage undefined.
[ERROR]   htlatex: ?    233      LaTeX Error: Missing \begin{document}.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ?    221      LaTeX Error: Environment titlepage undefined.
[ERROR]   htlatex: ?    233      LaTeX Error: Missing \begin{document}.
--- warning --- Ignoring \special{t4ht.xhtml}
HTML Tidy for Linux version 5.6.0
[STATUS]  tex4ebook: Conversion finished

@DavidGriffith
Copy link
Author

Here's the titlepage environment I tried:

\begin{titlepage}
\makeatletter
\@ifundefined{ebook}{
  \vspace*{\fill}
  \thispagestyle{empty}
  \begin{center}
  \includesvg{title}
  \end{center}
  \vspace*{\fill}
}{
  \coverimage{cover.svg}
  \includegraphics{title.svg}
}
\makeatother
\end{titlepage}

@DavidGriffith
Copy link
Author

Seems like the titlepage environment in the preamble is not okay for the memoir class. I used the titlingpage environment as suggested in https://tex.stackexchange.com/questions/66370/titlingpage-use-in-memoir-class, which resulted in what I want in the right place, but this didn't result in the <title> element getting set unless I also used \maketitle. I don't want that simple title page.

@michal-h21
Copy link
Owner

You need to provide the title somewhere. You can it after \coverimage:

\coverimage{cover.svg}
\includegraphics{title.svg}
\Tag{TITLE+}{My title}
\Configure{SafeTitle}{My title}

\Tag{TITLE+} will insert title in the HTML file, \Configure{SafeTitle} to ebook metadata.

@DavidGriffith
Copy link
Author

You need to provide the title somewhere. You can it after \coverimage:

\coverimage{cover.svg}
\includegraphics{title.svg}
\Tag{TITLE+}{My title}
\Configure{SafeTitle}{My title}

\Tag{TITLE+} will insert title in the HTML file, \Configure{SafeTitle} to ebook metadata.

Thanks! With that, epubcheck is now reporting zero errors. What now remains is to figure out how to embed fonts into my SVG files. I've given up on trying to add these fonts into the book itself.

@michal-h21
Copy link
Owner

Thanks! With that, epubcheck is now reporting zero errors. What now remains is to figure out how to embed fonts into my SVG files. I've given up on trying to add these fonts into the book itself.

It is usually best to include outlines in the SVG file. Dvisvgm can do that using -n option, I think. I am sure other tools support it as well.

@DavidGriffith
Copy link
Author

DavidGriffith commented Jun 26, 2020

Going through the dvisvgm manpage, I don't think that it'll help for what I'm doing. I created the SVGs in Inkscape and dvisvgm seems to want to only convert from dvi to svg.

I've tried https:/BTBurke/svg-embed-font and https:/phauer/svg-buddy for this. Both were very brittle and ultimately didn't work. I'm rather surprised that Inkscape seems to still lack the capacity to embed fonts into SVGs.

@michal-h21
Copy link
Owner

I think you can only convert text to paths in Inkscape. It will probably result in a bigger file, but it should be quite portable.

@DavidGriffith
Copy link
Author

I did that for one of the fonts I'm using: "Animals". I'm getting the hang of embedding fonts directly into an SVG. As I wrap up for tonight, I think that I might be able to put the fonts into the EPUB and then have the @font-face declarations in the SVGs reference a file instead of having the base64-encoded entirety of the font there. I think it might be possible to have tex4ebook automate this, but I need to do more research on this and create a script to semi-automate the work.

@DavidGriffith
Copy link
Author

Since we seem to be continuing a discussion on fonts in a closed issue, I opened up a new one specifically for this topic at #71.

@claell
Copy link

claell commented Jul 30, 2024

I ran into this, recently.

Now, to fix this, can I just use this code somewhere in the LaTeX file?

\Tag{TITLE+}{My title}
\Configure{SafeTitle}{My title}

Or is something else needed in order to make this work (like a config file that was mentioned before, for example)?

@michal-h21
Copy link
Owner

@claell it is better to use the config file, but you can also add it to your TeX file if you really want. Something like this should work:

\documentclass{article}

\begin{document}
\ifdefined\HCode
\Tag{TITLE+}{My title}
\Configure{SafeTitle}{My title}
\fi
\end{document}

I use \ifdefined\HCode to run this code only with TeX4ht.

@claell
Copy link

claell commented Jul 30, 2024

Alright, thanks for the quick reply!

The reason why I ideally don't want to do it in the config file is that then I can't use a generalized one for all books, anymore.

@michal-h21
Copy link
Owner

OK, that makes sense :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants