From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/28724 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: jcr Newsgroups: gmane.text.pandoc Subject: Re: How to get \section[Short title]{Long title} in LaTeX output Date: Wed, 30 Jun 2021 02:54:30 -0700 (PDT) Message-ID: References: <4p2Sx0e_CqUgNm9ZcXR064fya9gybYYDVBTVMMIL9p1m2ynHgBzs30shkkVJnu0l2RqSKghQo5oi10jSV33BS6IBsvIhBhtyoExu-d3p3Kc=@protonmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_334_424395221.1625046870066" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3944"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDQLFNXWVILBBV766CDAMGQEMWYFIXA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 30 11:54:34 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f60.google.com ([209.85.161.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lyWvS-0000sX-5f for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 30 Jun 2021 11:54:34 +0200 Original-Received: by mail-oo1-f60.google.com with SMTP id t19-20020a4ae4130000b029023950cb8d35sf1158487oov.6 for ; Wed, 30 Jun 2021 02:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=WlmuG9ev0jYl70iblIZIcUhIuX3A9uEA7wGmOxcEvF8=; b=PX1IrHHF4sW+n3ltuZmTxrPl5unvOxP585ApUxA7pxawSklzUFaUhS9ZRl3BSlpNhQ GA5ykLv2ZZ9xUvU7gLkwvz9JXBQCNUxOnpGx7RynvMxY39dlFE2h1qAhzAJG7qAhaeTV Jumnt8KTHgBErwkIBdDVPNPrubdi3Y3rXng4/LvFZYQfWrIVUEfO3CtjgQneQjD8PMzL DdM1IHxV9BobmoZNc49wyCAays7kq5ML6/0AatE5WkryMzx605iAAvr1//kN+oOjZYbR cocfZFp7HBkaoZ/Sth9egxnZNBn8OVHCb2ucAdG0nTaL5wNCAXLpIvo2NjH6vaepLg5y wNgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=WlmuG9ev0jYl70iblIZIcUhIuX3A9uEA7wGmOxcEvF8=; b=WXN6/y7K/EWGf1RoVoULFKtgDaDMO/DmBA8IgXKM2HT+as6wnfgN9X69AMiR/L/7wH 1d4wHvU/IkEukLzHfUFiwiYov3HXdFa9EcxAHNaf4bx1vBvsc1I/bMZlpFOdIE42flM8 dSsxWdc3e8N7Y78vPv7QBJzVZPzjRJ5FxEbra4kLNr2PZky+yBa3ZglBuzVEU4xO0vMS IyytJ65DuzHKGm+g94iTN7NrGboXyPUR3cSoenzxj7n2UrhRhKCXXMVPF0Kh+2EUXm0I h6RiL5fV/Z4RGOaOipglUNriML/BEwlXeC8jNZE55UNFbpDPYX8I1xmyjACN5Zz9DjAr 8ocA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=WlmuG9ev0jYl70iblIZIcUhIuX3A9uEA7wGmOxcEvF8=; b=A3EISLEXPgj/zvh2nxvLntJjalXuugmzs5HpEzL8RXBlAXznIa7Fl466Me0ZZKqkBt cMAh996u27pdSh7gyzDkWcYUsBKxY6AGWb/J2PjWUnwtQHhX61eoPUA6wIjsLPBz3uIN hoLhYv2wHsxN2S5r7jtVWBtSBDEfFLNLH6Lw9eyPNiGgFswOwzgP8R1sV77rtveR84Bs EZG1UerpH5jhjMWsvzB9jKioLhkK+vTkAQcM7OGsPSG8g1XMOhvZYIqcTmJLXi+lEkUm XnZobjBqnPlFdwt0pIc1vjIBNs1Lxa0M1xy2aMn//JeXokvFDo3khtqhMJ9uOLA4gJvW 8fhA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532G7tpnSseD9ogahwOuG82i6AXs9CMq2qkSTNdwmfOzCQsIhoju 6Eh3vu2C1Ix6uO4jzYIyazM= X-Google-Smtp-Source: ABdhPJw1vqH6/jeXciuPU8I4dddINEQ36S6rd6gR7VlXm0YL845JpmvT7OabUEef+07ZancgJ8pt8w== X-Received: by 2002:a4a:6f0e:: with SMTP id h14mr7683809ooc.9.1625046872774; Wed, 30 Jun 2021 02:54:32 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6830:2397:: with SMTP id l23ls588698ots.5.gmail; Wed, 30 Jun 2021 02:54:31 -0700 (PDT) X-Received: by 2002:a05:6830:187:: with SMTP id q7mr8582693ota.283.1625046870750; Wed, 30 Jun 2021 02:54:30 -0700 (PDT) In-Reply-To: X-Original-Sender: ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:28724 Archived-At: ------=_Part_334_424395221.1625046870066 Content-Type: multipart/alternative; boundary="----=_Part_335_568009123.1625046870066" ------=_Part_335_568009123.1625046870066 Content-Type: text/plain; charset="UTF-8" I did this with LaTeX and memoir: in my case, I only wanted a shorter title in the page headings. I kept the full title in the table of contents. These are the relevant functions from my filter: -- Print a formatted warning to stderr function warnf (...) io.stderr:write(string.format(...)) end function Header (el) -- Replace heading with raw LaTeX if pageheading is used to specify a -- shorter form of the title to use in page headers. if el.attributes.pageheading then local commands = {'chapter', 'section', 'subsection'} if el.level > #commands then warnf('pageheading attribute not supported for level %d headings', el.level) return el end -- Produce LaTeX like pandoc does, but with two additional arguments -- to specify a short for of the page heading to memoir. local title = pandoc.utils.stringify(el) local latexStr = string.format('\\%s[%s][%s]{%s}', commands[el.level], title, el.attributes.pageheading, title) local label = string.format('\\label{%s}', el.identifier) -- wrap in hypertarget latexStr = string.format('\\hypertarget{%s}{%%\n%s%s}', el.identifier, latexStr, label) return pandoc.RawBlock('latex', latexStr) end end On Wednesday, June 30, 2021 at 1:37:00 AM UTC+2 John MacFarlane wrote: > > Not easy. You could write a filter that builds the > relevant section command, but that might break other > things because the LaTeX writer won't see a heading > there (not sure). > > It might be a good idea to have pandoc do this automatically. > > "'Nick Bart' via pandoc-discuss" > writes: > > > Is there any way to have pandoc output LaTeX code like > > > > \section[Short Section Title]{Long Section Title} > > > > from pandoc markdown containing both versions as in the following (but > not necessarily given in this exact syntax)? > > > > # Long Section Title {short_title="Short Section Title"} > > > > -- > > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/4p2Sx0e_CqUgNm9ZcXR064fya9gybYYDVBTVMMIL9p1m2ynHgBzs30shkkVJnu0l2RqSKghQo5oi10jSV33BS6IBsvIhBhtyoExu-d3p3Kc%3D%40protonmail.com > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bc3ac76b-306d-4ab4-9a33-6acdd2d2a38fn%40googlegroups.com. ------=_Part_335_568009123.1625046870066 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I did this with LaTeX and memoir: in my case, I only wanted a shorter title= in the page headings. I kept the full title in the table of contents. Thes= e are the relevant functions from my filter:

-- Print= a formatted warning to stderr

function warnf (...)

  io.stderr:write(string.format(...))

end


function Header (el)

  -- Replace heading with raw LaTeX if pageheading is used to speci= fy a

  -- shorter form of the title to use in page headers.

  if el.attributes.pageheading then

    local commands =3D {'chapter', 'section', 'subsection'}

    if el.level > #commands then

      warnf('pageheading attribute not supported for leve= l %d headings', el.level)

      return el

    end

    -- Produce LaTeX like pandoc does, but with two additional= arguments

    -- to specify a short for of the page heading to memoir.

    local title =3D pandoc.utils.stringify(el)

    local latexStr =3D string.format('\\%s[%s][%s]{%s}', comma= nds[el.level], title, el.attributes.pageheading, title)

    local label =3D string.format('\\label{%s}', el.identifier= )

    -- wrap in hypertarget

    latexStr =3D string.format('\\hypertarget{%s}{%%\n%s%s}', = el.identifier, latexStr, label)

    return pandoc.RawBlock('latex', latexStr)

  end

end



On Wednesday, June 30, 2021 at 1:37:00 AM UTC+2 John MacFarlane wrote:=

Not easy. You could write a filter that builds the
relevant section command, but that might break other
things because the LaTeX writer won't see a heading
there (not sure).

It might be a good idea to have pandoc do this automatically.

"'Nick Bart' via pandoc-discuss"
<pandoc-...@googlegroups.= com> writes:

> Is there any way to have pandoc output LaTeX code like
>
> \section[Short Section Title]{Long Section Title}
>
> from pandoc markdown containing both versions as in the following = (but not necessarily given in this exact syntax)?
>
> # Long Section Title {short_title=3D"Short Section Title"= ;}
>
> --=20
> 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-discus..= .@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4p2Sx0e_CqUg= Nm9ZcXR064fya9gybYYDVBTVMMIL9p1m2ynHgBzs30shkkVJnu0l2RqSKghQo5oi10jSV33BS6I= BsvIhBhtyoExu-d3p3Kc%3D%40protonmail.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/bc3ac76b-306d-4ab4-9a33-6acdd2d2a38fn%40googlegroups.= com.
------=_Part_335_568009123.1625046870066-- ------=_Part_334_424395221.1625046870066--