public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: HTML to latex: Controlling table column width
Date: Thu, 29 Oct 2020 20:31:57 +0100	[thread overview]
Message-ID: <CADAJKhCb2bYQdYd4W_0b2703T8f96SHe4tYBVJDkofZ1Z1pr7Q@mail.gmail.com> (raw)
In-Reply-To: <CADAJKhCO9SFYvP9_Xg_NQe4NjHY8f-Xz6BJJy9CFY9ynvFzn-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 9648 bytes --]

I forgot the attachment!

-- 
Better --help|less than helpless

Den tors 29 okt. 2020 20:24BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> Often the problem with too  wide tables is that the column headers are
> wide while the contents of the regular rows are not. In such a case a
> useful LaTeX trick is to rotate the header contents and remove / reduce
> their nominal width so that they appear slanted with a reasonable amount of
> whitespace around them. With Pandoc I nowadays use a custom box command
> defined through the adjustbox package and a filter to inject that command
> into the column headers. The LaTeX part is, thanks to the work of the
> author of the adjustbox package, very easy and clean:
>
> ``````latex
> \usepackage{adjustbox}
>
> \newadjustboxcmd{\aH}{scale=0.85,rotate=60,left=1em}
>
> % \let\toprule\relax
> % \let\bottomrule\relax
> ``````
>
> Note that the order of the parameters in the `\newadjustboxcmd` definition
> is significant! `left=1em` left-aligns the content in the box *and* sets
> the width of the box — both crucial. You may want to remove the scaling,
> but I think it looks slightly better with it.
>
> I then use a Lua filter to "wrap" the header contents in this command, and
> at the same time setting the nominal column widths to zero so as to make
> the width "automatic", i.e. LaTeX decides the widths. Note that this filter
> presupposes that the table can successfully be converted to and from a
> SimpleTable!
>
> ``````lua
> -- LaTeX injects, to be reused.
> local pre = pandoc.RawInline('latex', '\\aH{')
> local post = pandoc.RawInline('latex', '}')
>
> function Table (tab)
>   -- Convert the complex Table into a SimpleTable
>   local simple = pandoc.utils.to_simple_table(tab)
>   -- Inject LaTeX code into the headers
>   for _,head in ipairs(simple.headers) do
>   -- Check that the header contains only one block
>     if #head == 1 then
>       -- Check that that block is a Para or Plain
>       if 'Para' == head[1].tag or 'Plain' == head[1].tag then
>         -- Insert the LaTeX before...
>         table.insert(head[1].content, 1, pre)
>         -- ...and after the Para/Plain content
>         table.insert(head[1].content, post)
>       end
>     end
>   end
>   -- Reset column widths
>   for i=1, #simple.widths do
>     simple.widths[i] = 0.0
>   end
>   return pandoc.utils.from_simple_table(simple)
> end
> ``````
>
> The result can be seen in the attached PDF. You may want to remove the top
> and bottom rules from tables to make this look better. To do so just
> uncomment the two commented lines in the LaTeX snippet above.
>
> Copy the LaTeX snippet in a file `adjust-table-head.ltx` and the Lua code
> in a file `adjust-table-head.lua` and then add `-L adjust-table-head.lua -H
> adjust-table-head.ltx`  to the pandoc command line.
>
>
> --
> Better --help|less than helpless
>
> Den ons 28 okt. 2020 13:02'Oliver Demetz' via pandoc-discuss <
> pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev:
>
>> Hi,
>>
>> I am converting HTML tables to latex. Problems arise if the table is
>> large and has many columns.
>> This table's cols add up to 99%,
>> ```
>> <table class="table table-bordered table-sm small" style="width: 100%;">
>>   <colgroup>
>>     <col width="14%">
>>     <col width="6%">
>>     <col width="6%">
>>     <col width="20%">
>>     <col width="11%">
>>     <col width="13%">
>>     <col width="7%">
>>     <col width="7%">
>>     <col width="15%">
>>     </colgroup>
>>     <thead>
>>     <tr>
>>         <th>Risiko (Beschreibung)</th>
>>         <th>Eintritts­wahr­schein­lichkeit</th>
>>         <th>Netto-Schadens­höhe</th>
>>         <th>Durchzuführende Gegenmaßnahmen</th>
>>         <th>Frühwarn­indikator</th>
>>         <th>Schwellwert</th>
>>         <th>Beob­achtungs­intervall</th>
>>         <th>Risiko­verantwort­licher</th>
>>         <th>Anmerkungen</th>
>>     </tr>
>>     </thead>
>>     <tbody>
>>     <tr>
>>         <td>(Einzel)-Kundenausfall<br>(bla bla blabla dasdf)</td>
>>         <td>mittel</td>
>>         <td>&lt; 1 T€</td>
>>         <td>a) Beauftragung eines Inkassounternehmens zur Beitreibung der
>> Forderung<br>b) Rücküberführung der Forderung auf den Mandanten
>> (Arztpraxis) wenn vertraglich vereinbart</td>
>>         <td>OP-Liste</td>
>>         <td>laut Kundenstamm</td>
>>         <td>monatlich</td>
>>         <td>Automatisch durch Software<br>Report an GF</td>
>>         <td>siehe Handbuch Kapitel Adressausfallrisiko</td>
>>     </tr>
>> </table>
>> ```
>> but the resulting minipages only have 75% \columnwidth. I know that there
>> is other spacing for the grid necessary, but especially now with 8 columns
>> any space is important.
>>
>> What can I do here to get full width tables.
>>
>> Thank you all in advance!
>>
>>
>> https://pandoc.org/try/?text=%3Ctable+class%3D%22table+table-bordered+table-sm+small%22+style%3D%22width%3A+100%25%3B%22%3E%0A++%3Ccolgroup%3E++++++++%0A++++%3Ccol+width%3D%2214%25%22%3E%0A++++%3Ccol+width%3D%226%25%22%3E++++++++++++%0A++++%3Ccol+width%3D%226%25%22%3E++++++++++++++%0A++++%3Ccol+width%3D%2220%25%22%3E++++++++++++++++%0A++++%3Ccol+width%3D%2211%25%22%3E++++++++++++++++++%0A++++%3Ccol+width%3D%2213%25%22%3E++++++++++++++++++++%0A++++%3Ccol+width%3D%227%25%22%3E++++++++++++++++++++++%0A++++%3Ccol+width%3D%227%25%22%3E++++++++++++++++++++++++%0A++++%3Ccol+width%3D%2215%25%22%3E++++++++++++++++++++++++%0A++++%3C%2Fcolgroup%3E++++%0A++++%3Cthead%3E+++%0A++++%3Ctr%3E%0A++++++++%3Cth%3ERisiko+(Beschreibung)%3C%2Fth%3E%0A++++++++%3Cth%3EEintritts%C2%ADwahr%C2%ADschein%C2%ADlichkeit%3C%2Fth%3E%0A++++++++%3Cth%3ENetto-Schadens%C2%ADh%C3%B6he%3C%2Fth%3E%0A++++++++%3Cth%3EDurchzuf%C3%BChrende+Gegenma%C3%9Fnahmen%3C%2Fth%3E%0A++++++++%3Cth%3EFr%C3%BChwarn%C2%ADindikator%3C%2Fth%3E%0A++++++++%3Cth%3ESchwellwert%3C%2Fth%3E%0A++++++++%3Cth%3EBeob%C2%ADachtungs%C2%ADintervall%3C%2Fth%3E%0A++++++++%3Cth%3ERisiko%C2%ADverantwort%C2%ADlicher%3C%2Fth%3E%0A++++++++%3Cth%3EAnmerkungen%3C%2Fth%3E%0A++++%3C%2Ftr%3E%0A++++%3C%2Fthead%3E%0A++++%3Ctbody%3E%0A++++%3Ctr%3E%0A++++++++%3Ctd%3E(Einzel)-Kundenausfall%3Cbr%3E(bla+bla+blabla+dasdf)%3C%2Ftd%3E%0A++++++++%3Ctd%3Emittel%3C%2Ftd%3E%0A++++++++%3Ctd%3E%26lt%3B+1+T%E2%82%AC%3C%2Ftd%3E%0A++++++++%3Ctd%3Ea)+Beauftragung+eines+Inkassounternehmens+zur+Beitreibung+der+Forderung%3Cbr%3Eb)+R%C3%BCck%C3%BCberf%C3%BChrung+der+Forderung+auf+den+Mandanten+(Arztpraxis)+wenn+vertraglich+vereinbart%3C%2Ftd%3E%0A++++++++%3Ctd%3EOP-Liste%3C%2Ftd%3E%0A++++++++%3Ctd%3Elaut+Kundenstamm%3C%2Ftd%3E%0A++++++++%3Ctd%3Emonatlich%3C%2Ftd%3E%0A++++++++%3Ctd%3EAutomatisch+durch+Software%3Cbr%3EReport+an+GF%3C%2Ftd%3E%0A++++++++%3Ctd%3Esiehe+Handbuch+Kapitel+Adressausfallrisiko%3C%2Ftd%3E%0A++++%3C%2Ftr%3E%0A%3C%2Ftable%3E&from=html&to=latex&standalone=0
>>
>> This table
>> <table class="table table-bordered table-sm small" style="width: 100%;">
>>   <colgroup>
>>    <col width="14%">          <col width="6%">            <col
>> width="6%">              <col width="20%">                <col
>> width="11%">                  <col width="13%">                    <col
>> width="7%">                      <col width="7%">
>> <col width="15%">                        </colgroup>    <thead>    <tr>
>>         <th>Risiko (Beschreibung)</th>
>>         <th>Eintritts­wahr­schein­lichkeit</th>
>>         <th>Netto-Schadens­höhe</th>
>>         <th>Durchzuführende Gegenmaßnahmen</th>
>>         <th>Frühwarn­indikator</th>
>>         <th>Schwellwert</th>
>>         <th>Beob­achtungs­intervall</th>
>>         <th>Risiko­verantwort­licher</th>
>>         <th>Anmerkungen</th>
>>     </tr>
>>     </thead>
>>     <tbody>
>>     <tr>
>>         <td>(Einzel)-Forderungsausfall<br>(Patient begleicht die Rechnung
>> nicht)</td>
>>         <td>mittel</td>
>>         <td>&lt; 1 T€</td>
>>         <td>a) Beauftragung eines Inkassounternehmens zur Beitreibung der
>> Forderung<br>b) Rücküberführung der Forderung            auf den Mandanten
>> (Arztpraxis) wenn vertraglich vereinbart        </td>
>>         <td>OP-Liste</td>
>>         <td>laut Kundenstamm</td>
>>         <td>monatlich</td>
>>         <td>Automatisch durch Software<br>Report an GF</td>
>>         <td>siehe Handbuch <a href="
>> http://10.3.6.9:802/report/render/5bc3db60-5c7d-47b7-9cd1-83bc3b93fd5d#adressenausfallrisiko"
>> target="_blank">Kapitel Adressausfallrisiko</a></td>
>>     </tr>
>>
>> --
>> 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/848a5b18-0f4a-482e-ba35-d3af80f2a2aan%40googlegroups.com
>> <https://groups.google.com/d/msgid/pandoc-discuss/848a5b18-0f4a-482e-ba35-d3af80f2a2aan%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/CADAJKhCb2bYQdYd4W_0b2703T8f96SHe4tYBVJDkofZ1Z1pr7Q%40mail.gmail.com.

[-- Attachment #1.2: Type: text/html, Size: 16016 bytes --]

[-- Attachment #2: test.pdf --]
[-- Type: application/pdf, Size: 9235 bytes --]

  parent reply	other threads:[~2020-10-29 19:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 12:01 'Oliver Demetz' via pandoc-discuss
     [not found] ` <848a5b18-0f4a-482e-ba35-d3af80f2a2aan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-28 17:18   ` John MacFarlane
     [not found]     ` <m2imauuv4g.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-29  9:44       ` 'Oliver Demetz' via pandoc-discuss
     [not found]         ` <cecc57bd-2768-4124-962e-bb5f835cfd95n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-29 17:23           ` John MacFarlane
     [not found]             ` <m2imatrlne.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-29 18:31               ` John MacFarlane
     [not found]                 ` <m21rhgsx2p.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-29 18:54                   ` John MacFarlane
     [not found]                     ` <m2r1pgrhgx.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-11-02 16:16                       ` 'Oliver Demetz' via pandoc-discuss
     [not found]                         ` <e6e8f94d-0e94-4f6d-b03c-2325494177b8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-11-02 16:37                           ` Albert Krewinkel
2020-10-29 19:24   ` BPJ
     [not found]     ` <CADAJKhCO9SFYvP9_Xg_NQe4NjHY8f-Xz6BJJy9CFY9ynvFzn-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-29 19:31       ` BPJ [this message]
     [not found]         ` <CADAJKhCb2bYQdYd4W_0b2703T8f96SHe4tYBVJDkofZ1Z1pr7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-29 19:40           ` 'Oliver Demetz' via pandoc-discuss
     [not found]             ` <78d5fb66-4211-47b3-97b1-e8402b8e243dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-29 19:56               ` BPJ
     [not found]                 ` <CADAJKhBWnr54SSbjoKHV8bqRkfkD7gKX2kkrLXUjT4Twfgy9Qw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-29 20:11                   ` 'Oliver Demetz' via pandoc-discuss
     [not found]                     ` <07d2b48b-e6b9-418a-b116-fdea9b92ae0bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-29 20:33                       ` BPJ
     [not found]                         ` <CADAJKhCi9r1XWV1J3cydLDy_vmkR_1yWZtimgZRTxCSdAO+rcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-30 15:51                           ` BPJ
2020-10-30 15:29                   ` Albert Krewinkel
     [not found]                     ` <87sg9vlokd.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-10-30 20:04                       ` BPJ

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=CADAJKhCb2bYQdYd4W_0b2703T8f96SHe4tYBVJDkofZ1Z1pr7Q@mail.gmail.com \
    --to=melroch-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).