public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Nikolay Yakimov <g.livid-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: How to enclose reference list entries in a latex environment?
Date: Sat, 28 Mar 2015 01:15:51 +0000	[thread overview]
Message-ID: <CA+hqrpXKM4mE7BBph71oc+GzE0PRbd51+uu-bkFkne7XdDg8bA@mail.gmail.com> (raw)
In-Reply-To: <584f68ea-db87-4c21-9c13-10d8f6a9118f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4552 bytes --]

import Text.Pandoc.JSON

main :: IO ()
main = toJSONFilter addHangPara

addHangPara :: Maybe Format -> Block -> Block
addHangPara (Just (Format "latex")) (Div ("",["references"],[]) (h@(Header
_ _ _):(Para ils):rest)) =
  Div ("",["references"],[]) $ h : (Para (RawInline (Format "latex")
"\\begin{hangpara}\n" : ils)) : rest ++ [RawBlock (Format "latex")
"\\end{hangpara}"]
addHangPara _ x = x

That would add \begin{hangpara} at the beginning of first paragraph
following reference section header. But honestly, at this point, it's
easier to use sed. Not sure where did you get \hyperdef{}{ref-item2}{} --
to my knowledge, pandoc-citeproc does not produce this.

сб, 28 марта 2015 г. в 1:23, <nickbart1980-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:

> Ok, John's latest version works after replacing `addHangPara (Format
> "latex")` by `addHangPara (Just (Format "latex"))`. Nick Yakimov’s code
> worked too when I tried that again. Thank you both!
>
> Unfortunately, this wasn't all. It turns out that the hangparas
> environment from hanging.sty does not work well and frequently leads to
> underfull pages in the bibliography (sometimes just half full).
>
> A better solution for a hangparas environment requires the scrartcl
> package (which is nice anyway) or at least the scrextend package, and looks
> like this:
>
> \newenvironment{hangparas}[1][2em]{%
>   \addmargin[#1]{0pt}\setlength{\parindent}{-#1}\hspace*{-#1}%
>   \ignorespaces
> }{%
>   \endaddmargin
> }
>
> This, however, leads to extra vertical space in the pdf output between the
> section header and the first entry unless the empty line between
> \begin{hangparas} and the first reference list entry is removed. There's
> also a horizontal space before the first entry; this can be fixed by
> inserting a `%` at the end of the `\hyperdef{}{ref-item2}{}` line
> (inserting `%` signs at the ends of lines is a routine precaution in latex
> anyway).
>
> This means that the beginning of a References section should look like
> this:
>
> ~~~~
>
> \section*{References}\label{references}
> \addcontentsline{toc}{section}{References}
>
> \begin{hangparas}
> \hyperdef{}{ref-item2}{}%
>
> Doe, John. ``Article.'' \emph{Journal of Generic Studies} 6, no. 4 (2006):
> 33--34.
>
> ~~~~
>
> So, (1) can the filter be modified to remove the empty line after
> `\begin{hangparas}`?
>
> And (2), can the latex writer be patched to insert a `%` after each
> `\hyperdef{}{ref-...}{}%` line?
>
>
>
> On Friday, March 27, 2015 at 6:28:07 PM UTC, John MacFarlane wrote:
>>
>> +++ John MacFarlane [Mar 27 15 11:20 ]:
>>
>> Sorry again, I put that in the wrong place.  Fix to the fix:
>>
>>     addHangPara :: Maybe Format -> Block -> Block
>>     addHangPara (Format "latex") (Div ("",["references"],[]) (h@(Header
>> _ _ _) : blocks)) =
>>       Div ("",["references"],[]) ( [h, latex "\\begin{hangparas}"] ++
>>         blocks ++ [latex "\\end{hangparas}"] )
>>       where latex = RawBlock (Format "latex")
>>     addHangPara _ x = x
>>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pandoc-discuss/ghOOvbHByLk/unsubscribe.
> To unsubscribe from this group and all its topics, 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/584f68ea-db87-4c21-9c13-10d8f6a9118f%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/584f68ea-db87-4c21-9c13-10d8f6a9118f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BhqrpXKM4mE7BBph71oc%2BGzE0PRbd51%2Buu-bkFkne7XdDg8bA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 6111 bytes --]

  parent reply	other threads:[~2015-03-28  1:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26 19:57 nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <ce053b54-950b-497b-ba33-f0a43c0dd559-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27  4:05   ` John MacFarlane
     [not found]     ` <20150327040534.GC35873-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-27  8:19       ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]         ` <4cd4b00d-3b34-4c19-8b2c-59b6e66eee7d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27 11:17           ` Nick Yakimov
     [not found]             ` <e881c6dc-b3ad-425d-a1d5-7e030adb9d68-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27 14:46               ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                 ` <d6015803-4bdd-4cab-bb75-3d502ef8cb08-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27 18:26                   ` John MacFarlane
2015-03-27 18:20           ` John MacFarlane
     [not found]             ` <20150327182009.GB37676-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-27 18:27               ` John MacFarlane
     [not found]                 ` <20150327182752.GD37676-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-27 22:22                   ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                     ` <584f68ea-db87-4c21-9c13-10d8f6a9118f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28  1:15                       ` Nikolay Yakimov [this message]
2015-03-28  3:17                       ` John MacFarlane
     [not found]                         ` <20150328031718.GD37821-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-28  9:52                           ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                             ` <08aa7ab5-40b2-45f2-8a86-635c75018bb9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 10:05                               ` Nikolay Yakimov
     [not found]                                 ` <CA+hqrpVmrGj7a4G2Ss1FdXkgn=QQXNiK9Smg7aGYxyH2naYdiw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-28 12:22                                   ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                                     ` <472e1709-92d6-4c1d-961d-edad2b55bfd0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 13:10                                       ` Nick Yakimov
     [not found]                                         ` <9f84082a-3ad0-40f2-b0f5-ad564cbe5d24-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 14:28                                           ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                                             ` <46a6f65e-a2fe-4207-bbf2-0c96524ebe7d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 14:40                                               ` Nick Yakimov
     [not found]                                                 ` <8efa389a-8880-491d-8f18-7e8ae1b38669-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 15:19                                                   ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
2015-03-28 15:27                                                   ` John MacFarlane
     [not found]                                                     ` <20150328152704.GC49524-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-28 17:02                                                       ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w

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=CA+hqrpXKM4mE7BBph71oc+GzE0PRbd51+uu-bkFkne7XdDg8bA@mail.gmail.com \
    --to=g.livid-re5jqeeqqe8avxtiumwx3w@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).