For clarity: the hanging indent filter above inserts `\item` in front of every entry, and requires the definition of a  `references` environment in a template:

~~~
\newenvironment{references} {\list{}{% hanging indent, src/myfilters/addRefEnvItem.hs
    \leftmargin1.5em%
    \itemindent-\leftmargin%
    \itemsep0.5ex%
    \parsep0pt%
    }}
    {\endlist}
~~~

I wonder whether the latex writer itself shouldn’t insert such a `references` environment by default. Hanging indent is required by many styles anyway but could be redefined as necessary.

Even better, pandoc(-citeproc) could parse the CSL `hanging` and `second-field-align` flags, and inject appropriate formatting instructions into the `references` environment.


On Monday, August 31, 2015 at 7:09:15 AM UTC, nickba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
I have a filter that adds the needed raw latex commands:

~~~
#!/usr/bin/env runhaskell

-- addRefEnvItem.hs

import Text.Pandoc.JSON

main :: IO ()
main = toJSONFilter addRefEnvItem

addRefEnvItem :: Maybe Format -> Block -> Block
addRefEnvItem (Just (Format "latex"))
  (Div ("",["references"],[]) (h@(Header _ _ _) : blocks)) =
  Div ("",["references"],[])
    ( [h, latex "\\begin{references}\\sloppy"] ++
    concatMap addItem blocks ++ [latex "\\end{references}"] )
  where latex = RawBlock (Format "latex")
addRefEnvItem _ x = x

addItem :: Block -> [Block]
addItem x = [RawBlock (Format "latex") "\\item", x]
~~~

… but it has stopped working after the latest updates. What are the adjustments needed?

On Monday, August 31, 2015 at 5:54:33 AM UTC, John MacFarlane wrote:
+++ Andrew Dunning [Aug 30 15 13:06 ]:
>   Will this also allow for the insertion of extra markup through a
>   template? (For instance, a LaTeX class I am using wants the
>   bibliography to be surrounded
>   by \begin{thebibliography}...\end{thebibliography}, and it would be
>   fantastic to be able to achieve that.)

The bibliography was never part of a template and still
isn't.  It is inserted directly into the document body.

There are various ways to achieve what you want.  One is
write a simple filter that can run after pandoc-citeproc.
It would intercept a Div with id = references, and
add the needed raw latex commands to the beginning and end
of its contents.

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ea6da5d7-d98f-47f9-be3e-193adaa10333%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.