From: jiewuza <jiewuza-9Onoh4P/yGk@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Pandoc-crossref adds latex `codelisting` env (not found on CTAN) for code block
Date: Sat, 29 Sep 2018 14:32:29 +0800 [thread overview]
Message-ID: <m2y3bkak5e.fsf@163.com> (raw)
In-Reply-To: <m2h8ia8cvc.fsf@johnmacfarlane.net>
I see. I use a customized template.
There is `usepackage{listings}` in it. But pandoc-crossref does not
insert:
```
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
```
I will add it in my template.
Thanks.
John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
> pandoc-crossref should be inserting something like
> this:
>
> \@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
> \floatname{codelisting}{Listing}
> \newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
>
>
> which definse codelisting. This requires that you
> have \usepackage{listings} in your preamble.
> Normally it would be included in the default template
> when you use --listings and have code, but I think the normal
> mechanism for this being defeated because the code is
> replaced by raw latex by pandoc-crossref. (At least
> that's my speculation, you'd have to confirm this with
> pandoc-crossref's maintainer.)
>
> Anyway, I found that if I generated a file with
>
> -o my.tex -s --listings --filter pandoc-citeproc
>
> and then manually added `\usepackage{listings}` to the
> preamble, it would compile using pdflatex.
>
> So you should be able to get this to work by using
> this in your document's metadata:
>
> header-includes:
> - `\usepackage{listings}`{=latex}
>
> pandoc-crossref should probably be adding this
> itself.
>
> jiewuza <jiewuza-9Onoh4P/yGk@public.gmane.org> writes:
>
>> Here is the code block in my md file:
>> ```{#lst:captionAttr .haskell caption="Listing caption"}
>> main :: IO ()
>> main = putStrLn "Hello World!"
>> ```
>>
>> With `pandoc test.md -o test.tex --listings`, the output is:
>> ```
>> \begin{lstlisting}[language=Haskell, caption={Listing caption}, label=lst:captionAttr]
>> main :: IO ()
>> main = putStrLn "Hello World!"
>> \end{lstlisting}
>> ```
>>
>> With `pandoc test.md -o test.tex --listings --filter pandoc-crossref`,
>> the output is:
>> ```
>> \begin{codelisting}
>> \caption{Listing caption}
>>
>> \begin{lstlisting}[language=Haskell, caption={Listing caption}, label=lst:captionAttr]
>> main :: IO ()
>> main = putStrLn "Hello World!"
>> \end{lstlisting}
>>
>> \end{codelisting}
>> ```
>>
>> But I cannot find the `codelisting` on CTAN.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to
>> pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pandoc-discuss/m2a7o3xr67.fsf%40163.com.
>> For more options, visit https://groups.google.com/d/optout.
next prev parent reply other threads:[~2018-09-29 6:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-27 8:47 jiewuza
[not found] ` <m2a7o3xr67.fsf-9Onoh4P/yGk@public.gmane.org>
2018-09-28 4:28 ` John MacFarlane
2018-09-29 6:32 ` jiewuza [this message]
[not found] ` <m2y3bkak5e.fsf-9Onoh4P/yGk@public.gmane.org>
2018-09-29 6:49 ` John MacFarlane
2018-09-30 3:24 ` jiewuza
2018-09-30 3:38 ` jiewuza
[not found] ` <m2pnwvac3y.fsf-9Onoh4P/yGk@public.gmane.org>
2018-09-30 6:00 ` John MacFarlane
2018-09-30 6:16 ` jiewuza
[not found] ` <m2lg7ja4ro.fsf-9Onoh4P/yGk@public.gmane.org>
2018-10-01 5:57 ` John MacFarlane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2y3bkak5e.fsf@163.com \
--to=jiewuza-9onoh4p/ygk@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).