From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/28726 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'Nick Bart' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: How to get \section[Short title]{Long title} in LaTeX output Date: Wed, 30 Jun 2021 12:29:57 +0000 Message-ID: References: <4p2Sx0e_CqUgNm9ZcXR064fya9gybYYDVBTVMMIL9p1m2ynHgBzs30shkkVJnu0l2RqSKghQo5oi10jSV33BS6IBsvIhBhtyoExu-d3p3Kc=@protonmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="b1_VOfXScosiayWnK8O1HCvl62usXpte8pjxeTdUaxX3s" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5567"; mail-complaints-to="usenet@ciao.gmane.io" To: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org" Original-X-From: pandoc-discuss+bncBDR4BGVI44MRBS6H6GDAMGQEDLCADHI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 30 14:30:06 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f57.google.com ([209.85.128.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lyZLy-0001Cn-8k for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 30 Jun 2021 14:30:06 +0200 Original-Received: by mail-wm1-f57.google.com with SMTP id t82-20020a1cc3550000b02901ee1ed24f94sf2745630wmf.9 for ; Wed, 30 Jun 2021 05:30:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1625056206; cv=pass; d=google.com; s=arc-20160816; b=Fvj3oYo4jSS6J9gHVJ8oDtkqy4VU02V7XchnMwTcpZCkAMiimavX7Fo4yM8APpK8kG ihzZ8NCA7BFFJkzB9OQgFZiWfgbfgszoene0Q2uYKgwyKE/HOdH8tFy8ATLzvWKZwoPm ZWpzBaaXUmnrADRbprdyYQMC3+fzBQ+4+zyGy+8ab2ePMR8cBIuQhY2Mw2WNbNLnJkmH GLBtumk2csr7E1B24PaGOaKZFD2ad1EMsAqv1AvWB6jTuZKVrtGBP/PtGVn7d1VU/4V5 YewQiKEsJoXi5VgylCYcQHSTF8KiYMuwAcACI/IcES+8nn2VSBThJOCJRcbYn63VISfG tMsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:subject:reply-to:from:to:date:dkim-signature; bh=a74PZZ7YQ8WPHhmxMpMHXZbfoWYaynxfx+jXVlny7go=; b=GWyF2tl76evbfQlpA1JeQ6D9hJH3sY48j3D1ot7Lz3j9y8dtzciiLqQqyNwE1zwL77 al+alFPFDEpjCZo5CxaJk7+vtLd0hyyiDKbkMgov3/+IB3jAakKQcaZVD0Bd2gjYUHMG xjoIOYg0ukgn11hsSbYg7LbrQmKdHH1nWg8NA+5bQ7nxzGYo+WtKBorOpE2Ihfr7eZoR HQJBPpIhNbOAWJrOmibAYQEsaYZQHyqd3HJMQd4ce8iO/yhCV0xUsScZzV+Rm3k/0Onv 3ItFL2R4cxPsndbhhe+uQwhjRTmoYco+wj0xVeaROBurmYGW3bCKk8P0o4qnVmsCn4wZ Tvyw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=Q5cRNUjk; spf=pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.43.18 as permitted sender) smtp.mailfrom=njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=date:to:from:reply-to:subject:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=a74PZZ7YQ8WPHhmxMpMHXZbfoWYaynxfx+jXVlny7go=; b=FugOSdE85833T+hYgprMmzBNJElpg1mKjlz2MppEimazIPQGGCz7P0ZZELPzgrRvou d2nxabu84AzxYj7Fm5x+pTcDxUHVNhLxY4Up8fqzOvTNGkJtrAK1TBcD5enqRs8CNO/N QPahOAXQtoHA0sPlkapVDW3/U/1jRiQZ3inRhSJSA/zuoe8otZUTjs25GXG/hlI7YhqW yvcyGByv3DXq+ncnWVavz9RNYvniJobl08PFGcLENuYyzyLKtuU1OfoQzYNl7iI9n7Tm nkyK2579eMEkaLklXFex9iKMHYrWoTbeuVL+z4qI/KGDcEriyfnGq7WEPGjIzuhQ4NkS bx2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:to:from:reply-to:subject:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=a74PZZ7YQ8WPHhmxMpMHXZbfoWYaynxfx+jXVlny7go=; b=olmATaRZtz97o5D/cwj25Y8ekVLSmzBspG+wHX1EwrSQ1DCPD+zbqjsosj87oAUYhy 5tlu2Dz9ilS/XaKO6LfsNt2PUQbY1yUmS/spnHQZbs8Oa4Sx+0eF5E8p65iBxxRS719m ZVm8pTJdNN32A02kZYWg4GFOfhSSa2zCu7hPKruXLIEfQExnIdu1o3Zh2IZl/Rum34/Z wB2D6sJ6OYpYLab2P2P4jZRcDZvZdbZbGV2gElBfPKMGZkebeEODMgvhxRKTlfRha2XH gw081oMTsEV2w7MKHKEhXD8kJY5Ga7s1A5ClDbkmci/m+PuzACK++6If3wXHFjOJw2tH ru9g== X-Gm-Message-State: AOAM5324Vu0UP9ZzLequorY9LsCXuSpszI+YVeGrwEIe5mp7nfdh73Zj nfaYrDEsatwA9cUOWvMpl5k= X-Google-Smtp-Source: ABdhPJzFhAgiQCUQCrlHkxMNrdUCItvEmYcP9DXRzqPTIu6sKTMHn3a8/qnxb7d7oGitRtzctD4NJQ== X-Received: by 2002:a5d:5745:: with SMTP id q5mr12507604wrw.329.1625056205891; Wed, 30 Jun 2021 05:30:05 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:adf:ecd0:: with SMTP id s16ls289456wro.0.gmail; Wed, 30 Jun 2021 05:30:03 -0700 (PDT) X-Received: by 2002:a5d:6d06:: with SMTP id e6mr41224478wrq.28.1625056203230; Wed, 30 Jun 2021 05:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625056203; cv=none; d=google.com; s=arc-20160816; b=uR1E0cRjWPvVyWV2ZMTbJSz3KdCI22bEjY+h6FAKB6UqQNciua5TzxrPqSsa/MnAdI Cp7gRtrTP5/FOkt/6fsAYH7CMaxuN0j/5cDZaJmmgqQSHzubXJMWMirhuKtCuVwYpFYf qB57HXEAW8N/FlAGMMDHsgjDEZNu8T71t55ON8lOddsVT81kw1yv+3n+Woqj9VeGcutA //G5Dn/Fu80PvGWDkiR+cZSU3Nuq5/aQ+Z17lVKGRyGZ99mJ01IVy+cyVCPWS0pwnRON b/9bnX3xwOjsdKFhI0bk/p3ZKe+a5FaYRnIrXnLalR/diqPIPaPMfOXvWJd0+baToD5l Um3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:subject:reply-to :from:to:dkim-signature:date; bh=XM6o23CaDKU6TR2n8Mn/YswU+AOwjrhmCoq1RnBEcoE=; b=CN53RcmpqkroqDPYWbnGYlVe7yzM/Zi/3xGUuKO0eCkJRMkQaqbKWV0GpSRYm5FCma gw7mmxckI5+uMIHPteLRtscFruTqDZysos4oOUAl+NFAfedfC//nK+xsd6sdwK1UPS0s dsjRmyz4h0HC8J+xpUbB79v6tShDLbo2XKVela+vMFEwErF0C0cmCuQXhOQ8r2a8bghT vwZfRZlB0H8mCZ3glJBWqBPLBMZPB2KfHqGprsCGayaLRkBogC2k2LYGA1p9J8IFuY7l g0XkhCTMCY1u+xTcdSJmJFJGGfiGK6uV9jtlYjyyptad+q7wZmRbgcfg9sTTa8crB5hL DMkQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=Q5cRNUjk; spf=pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.43.18 as permitted sender) smtp.mailfrom=njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Original-Received: from mail-4318.protonmail.ch (mail-4318.protonmail.ch. [185.70.43.18]) by gmr-mx.google.com with ESMTPS id k18si417076wmj.0.2021.06.30.05.30.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 05:30:03 -0700 (PDT) Received-SPF: pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.43.18 as permitted sender) client-ip=185.70.43.18; In-Reply-To: X-Original-Sender: njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=Q5cRNUjk; spf=pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.43.18 as permitted sender) smtp.mailfrom=njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com X-Original-From: Nick Bart 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:28726 Archived-At: This is a multi-part message in MIME format. --b1_VOfXScosiayWnK8O1HCvl62usXpte8pjxeTdUaxX3s Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable @jcr - Brilliant, works like a charm. I had to make some trivial changes; t= he version I=E2=80=99m using right now with the LaTeX article or scrartcl c= lasses is shown below. One thing that would be nice to have, though, would be the ability to switc= h automatically between a 'commands' list for book-like LaTeX classes (star= ting with 'chapter'), and article-like classes (starting with 'section'). I= 'll be trying to figure that out, but useful hints would be welcome. -- 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 =3D {'chapter', 'section', 'subsection'} local commands =3D {'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 =3D pandoc.utils.stringify(el) -- local latexStr =3D string.format('\\%s[%s][%s]{%s}', commands[el.level],= title, el.attributes.pageheading, title) local latexStr =3D string.format('\\%s[%s]{%s}', commands[el.level], el.att= ributes.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, la= texStr, label) return pandoc.RawBlock('latex', latexStr) end end --=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 e= mail 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/Jhsov6mz1SVLhbvImsIGtDSG8qg-4qI-Zd5Qbgheu2-1jaeqQqvZoCWtG8V5= 0fuZTwajRjw07nWkok89_GCoZbdWOh2oZ6eo_T2uyFEWAcc%3D%40protonmail.com. --b1_VOfXScosiayWnK8O1HCvl62usXpte8pjxeTdUaxX3s Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
@jcr - Brilliant, works like a charm. I had to make some trivial chang= es; the version I=E2=80=99m using right now with the LaTeX article or scrar= tcl classes is shown below.

One thing that wo= uld be nice to have, though, would be the ability to switch automatically b= etween a 'commands' list for book-like LaTeX classes (starting with 'chapte= r'), and article-like classes (starting with 'section'). I'll be trying to = figure that out, but useful hints would be welcome.

-- Print a formatted warning to stderr
function warnf (= ...)
  io.stderr:write(string.format(...))
end
function Header (el)
  -- Replace hea= ding 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
    -- loca= l commands =3D {'chapter', 'section', 'subsection'}
 &nb= sp;  local commands =3D {'section', 'subsection'}
 =    if el.level > #commands then
  &nbs= p;   warnf('pageheading attribute not supported for level %d head= ings', el.level)
      return el
=
    end
    -- Produ= ce 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}', commands[el.level], title, el.attributes.pageheading, title= )
    local latexStr =3D string.format('\\%s[%= s]{%s}', commands[el.level], el.attributes.pageheading, title)
    local label =3D string.format('\\label{%s}', el.identi= fier)
    -- wrap in hypertarget
    latexStr =3D string.format('\\hypertarget{%s}{%%\n%s%s}= ', el.identifier, latexStr, label)
    return = pandoc.RawBlock('latex', latexStr)
  end
e= nd

--
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/msg= id/pandoc-discuss/Jhsov6mz1SVLhbvImsIGtDSG8qg-4qI-Zd5Qbgheu2-1jaeqQqvZoCWtG= 8V50fuZTwajRjw07nWkok89_GCoZbdWOh2oZ6eo_T2uyFEWAcc%3D%40protonmail.com.=
--b1_VOfXScosiayWnK8O1HCvl62usXpte8pjxeTdUaxX3s--