This is sort of a continuation of #1882, but is nonetheless a separate issue. #1882 contains all of the relevant info about my directory layout and what not. Here's what happens when I run pandoc lysa.ltx -f latex -t epub -o lysa.epub:
pandoc:
Error at "1-introduction.ltx" (line 1, column 27):
unexpected "{"
expecting letter or lf new-line
\documentclass[12pt]{book}
^
The problem is, the LaTeX it doesn't like is valid LaTeX; it compiles just fine with pdflatex. I'm not sure what the issue is here.
Thanks in advance.
Looking closely at the error message, it has an issue with 1-introduction.ltx, however that piece of text is from lysa.ltx. Here's 1-introduction.ltx:
\ch{Introduction}
Before I bore you with a bunch of crap you don't care about, let's do some math,
shall we?
There are basically three notions with which you need to be familiar in order to
do anything interesting in math. Those three things are {\it sets}, {\it
functions}, and {\it proofs}. Unfortunately, to be familiar with one, you have
to be familiar with the other two.\footnote{You'll learn as we go along, when
math people use a common term like {\it set}, {\it function}, {\it proof},
{\it group}, {\it continuous} or {\it closed}, they usually mean something
similar in concept to the colloquial term, but there are some strings
attached. This is usually the case in the sciences too (e.g. \xti{theory},
\xti{hypothesis}, \xti{experiment}).}
So, what are each of those things?
\begin{itemize}
\item A \xti{set} is an unordered collection of things. There is also no
repetition. For instance, $\mset{2, 5}$ is the same as $\mset{5, 2}$ (because
order doesn't matter). $\mset{2, 5, 5}$ would be the same set, because there's
no notion of multiplicity.
\item A \xti{function} is a mathematical construct (well, obviously, else I
wouldn't be talking about it). Basically, it takes some input, does something
to it, and spits out some output. If you give the function the same input a
bunch of times, you should get the same result each time. This concept is
called ``referential transparency.'' If the function is not referentially
transparent, then it's not a function. It's something else.
\item A \xti{proof} is basically where you take a bunch of simple facts, called
\xti{axioms}, and chain them together to make \xti{theorem}s. It's sort of like
sticking puzzle pieces together to form a picture.
The puzzle pieces (in this case, the axioms) aren't usually very interesting
on their own. However, the picture they form (in this case, the theorem) can
be really cool and enlightening. The proof would be analogous to an explicit
set of instructions explaining how to put the pieces together.
\end{itemize}
Once you are familiar with each of those concepts, we can do all sorts of cool
stuff. Throughout the book, we will prove all of the following:
\begin{itemize}
\item If you tap your finger against a bridge at exactly the right frequency,
the bridge will collapse. (Resonance)
\item The formula used to calculate the interest rate on your mortgage is
actually just a fancy form of the ratios of angles in a triangle. (Euler's
formula)
\item Logic can't be used to prove everything we know to be true. (Gödel's
incompleteness theorem)
\end{itemize}
\s{Introduction (for real this time)}
This is a math book. Well, duh. Why did I write it?
Most math (and science) books nowadays seem to value keeping an academic tone
over ensuring that the reader understands the material, and --- more importantly
--- enjoys reading the book.
I take the opposite approach. I want to create a book that is fun to read and
easy to understand, while eschewing the practice of making myself look good.
The inspiration for this book is \href{http://learnyouahaskell.com/}{{\it Learn
You a Haskell for Great Good!}, by Miran Lipovača}. Haskell is a programming
language, and LYAH is a great book for learning Haskell. If you are interested
in a print copy of LYAH, see \cite{lyah}.
There is also an incomplete and unofficial
\link{https://github.com/gazay/lysa}{Russian translation}, courtesy of Alexey
Gaziev.
\s{The community}
Despite the fact that I used ``I'' in the first part of the book, LYSA is
actually a community project, and many people participate in the writing of this
book.
If you want to talk to us, or to other math people, come see us in {\tt \#lysa}
on Freenode. If you don't know what IRC is, or you don't have a client set up,
you can connect through
\link{http://webchat.freenode.net/?channels=lysa}{Freenode's webchat}.
If you have any questions about LYSA (or math), feel free to ask in the IRC
channel ({\tt \#lysa} on FreeNode in case you forgot).
If you want to submit a correction, or have some issue, or want to add some
content, really anything having to do with the content of the book, you can
visit \link{https://gitlab.com/lysa/lysa}{our GitLab page}. We also have a
\link{http://learnyou.org}{woefully incomplete website} and a
\link{https://lysa.reddit.com/}{community on Reddit}.
\s{Idris}\label{intro-idris}
In this book, we cover a lot of hard stuff.\footnote{This isn't actually
true. Math isn't hard, stupid!} Sometimes, it's useful to program your way
through a problem. Every programmer will tell you that programming teaches a
manner of thinking.
Many programmers will cite Steve Jobs\footnote{For you youngsters, Steve Jobs is
the former CEO of Apple. He's dead now.} famous quote, regarding the use of
programming in his job,
\begin{iquote}
[sic] \ldots much more importantly, it had nothing to do with using [the
programs we wrote] for anything practical. It had to do with using them to be
a mirror of your thought process; to actually learn how to think. I think
everybody in this country should learn how to program a computer --- should
learn a computer language --- because it teaches you how to think.
\end{iquote}
\nocite{jobs-programming}
That first sentence or two is actually a pretty good description of mathematics
(and programming). Both are incredibly useful, and have endless practical
applications. That's not the point, though. The whole usefulness thing is a side
gig. It's about learning how to think, and having a rigorous language through
which to express your thoughts. Furthermore, the rigor of the language helps you
build upon your current thoughts to find out even cooler things. That's what
math is about.
Programming and math go hand-in-hand. Programmers and mathematicians will attest
to this; I certainly can. For that reason, throughout this book, there will be
coding exercises in the programming language Idris. Idris is an interesting
programming language for many reasons. The chief of which is that it can be used
to prove things mathematically. Most programming languages can't do this. Idris
can, which is why it is special.\footnote{There are other programming languages
that can prove things, namely Coq and Agda. However, I'm most familiar with
Idris, and Idris is probably the most useful, so I'm using Idris. Deal with
it.}
\ss{Installing Idris}
This is something that is actually rather difficult to summarize, because it
varies from operating system to operating system. I will put down the
instructions for the operating systems I use. If you come upon this and don't
see your operating system, please report this on
\link{https://gitlab.com/lysa/lysa/issues/new}{the issue tracker}. Better yet,
you could add the instructions yourself, and ask me to merge your changes.
\sss{Linux}
\pg{Gentoo}
You will need the Haskell platform, along with the GNU Multiple Precision (GMP)
library. As of 5 January 2015, the Haskell platform is only available on
\code{\tilde ARCH}, where \code{ARCH} is your processor architecture
(e.g. \code{amd64}, \code{x86}). If you use \code{ARCH}, you can enable these by
adding the following to \filepath{/etc/portage/package.keywords}:\footnote{If
you already use \code{\tilde ARCH}, you can ignore this}
\begin{plainfile}
dev-lang/ghc
dev-haskell/cabal-install
\end{plainfile}
Regardless of your \code{ACCEPT\_KEYWORDS} variable, you should add the
following to \filepath{/etc/portage/package.use}:
\begin{plainfile}
dev-lang/ghc binary
\end{plainfile}
Otherwise, you have to compile GHC (the Haskell compiler) from scratch, and that
takes forever.
Once you have that all out of the way, you'll want to run the following command as root:
\begin{shellsession}
# emerge -jav dev-lang/ghc dev-haskell/cabal-install
\end{shellsession}
\xtb{Warning}: \terminal{-j} will make the installation a lot faster, but is
more resource-intensive. If your power usage is precious, omit it (i.e. use
\terminal{-av} instead).
Once GHC and cabal-install are installed, you'll want to run the following as a
normal user:
\begin{shellsession}
% cabal update
% cabal install alex happy haddock hscolour
% cabal install idris
\end{shellsession}
You can then get at the Idris shell by running \terminal{idris}.
\s{Licensing}
This book is free, in the sense of freedom. You can copy this book and give it
to your friend. You can even print it out and sell it to your
friends.\footnote{There are some restrictions though, see \cref{gfdl}.}
If, for instance, you are a schoolteacher and want to use this for your class,
you are free to edit it to your liking and give the modified copy to your
students.
LYSA is licensed under the GNU Free Documentation License. \Cref{gfdl} contains
the license. Please read the license; it's actually pretty comprehensible.
The source for this book can be downloaded at
\url{https://gitlab.com/lysa/lysa/repository/archive.tar.gz}. If you are looking
to contribute, it's probably best to clone the git repository. You can clone the
git repository by running \terminal{git clone https://gitlab.com/lysa/lysa.git}
in a terminal.
Is \ch a standard latex command or a macro you have defined elsewhere?
This might be related to #1866
It's a macro defined elsewhere. (It's nonetheless defined before \ch is used.)
I think this is #1866
I'm not familiar enough with Pandoc's code to determine if this is #1866 . Your call.
I can confirm it's #1866. At least my fix for it works as expected on sample files given here as well.
@lierdakil can this be closed?
@jgm, I believe so, yes.
This issue seems to either have been incompletely fixed or re-introduced. The following macro in a pandoc template:
\newcommand*\phantomas[3][c]{%
\ifmmode{}
\makebox[\widthof{$#2$}][#1]{$#3$}%
\else
\makebox[\widthof{#2}][#1]{#3}%
\fi
}
Throws the following error when I run pandoc on it:
pandoc: "template" (line 47, column 24):
unexpected "#"
expecting letter
CallStack (from HasCallStack):
error, called at src/Text/Pandoc/Templates.hs:73:35 in pandoc-1.19.2.4-5NBbUZ9afMNXmVGq4ipbc:Text.Pandoc.Templates
If you've got latex in a template, you need to make sure to
escape each $ to $$, since $ is a special character
in pandoc templates.
+++ Simon Charlow [Oct 20 17 10:57 ]:
This issue seems to either have been incompletely fixed or
re-introduced. The following macro in a pandoc template:\newcommand*\phantomas[3][c]{%
\ifmmode{}
\makebox[\widthof{$#2$}][#1]{$#3$}%
\else
\makebox[\widthof{#2}][#1]{#3}%
\fi
}Throws the following error when I run pandoc on it:
pandoc: "template" (line 47, column 24):
unexpected "#"
expecting letter
CallStack (from HasCallStack):
error, called at src/Text/Pandoc/Templates.hs:73:35 in pandoc-1.19.2.4-5NBbUZ9
afMNXmVGq4ipbc:Text.Pandoc.Templates—
You are receiving this because you were mentioned.
Reply to this email directly, [1]view it on GitHub, or [2]mute the
thread.References
Thanks, that was indeed the issue. I'm surprised I'd never encountered the point about $ before, though of course I should have realized.
Most helpful comment
If you've got latex in a template, you need to make sure to
escape each
$to$$, since$is a special characterin pandoc templates.
+++ Simon Charlow [Oct 20 17 10:57 ]: