public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* HTML to latex: Controlling table column width
@ 2020-10-28 12:01 'Oliver Demetz' via pandoc-discuss
       [not found] ` <848a5b18-0f4a-482e-ba35-d3af80f2a2aan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: 'Oliver Demetz' via pandoc-discuss @ 2020-10-28 12:01 UTC (permalink / raw)
  To: pandoc-discuss


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

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.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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 19:24   ` BPJ
  1 sibling, 1 reply; 17+ messages in thread
From: John MacFarlane @ 2020-10-28 17:18 UTC (permalink / raw)
  To: 'Oliver Demetz' via pandoc-discuss, pandoc-discuss


We apply a (0.97)^n "scale factor" to make room for space between
columns, where n = the number of columns.

Looks like this gives bad results when n is large.  So this
formula needs to be tweaked.  Suggestions welcome. I don't
actually remember why we (I?) chose to make the scale factor
depend on the number of columns in this way, but it may have
been by experimenting...I assume I tried a constant factor
first and it didn't work.

I just tried your document (using pandoc -s)
and with the default latex template the table actually overflows
the textwidth.  I assume you're using very wide margins or a very
small font?

Even with 1 inch margins and 10pt font, the table takes up
nearly the whole textwidth and the contents are too wide for
the cells.  Only in landscape mode can I make it fit --
and then it actually looks pretty good, except for one
overlapping cell.

Relevant code is around l.854 of the LaTeX writer.

"'Oliver Demetz' via pandoc-discuss"
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:

> 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.

-- 
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/m2imauuv4g.fsf%40MacBook-Pro.hsd1.ca.comcast.net.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: 'Oliver Demetz' via pandoc-discuss @ 2020-10-29  9:44 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks for your reply. 

Yes I am typesetting this in landscape. However, in any page orientation, 
the minipages only occupy 0.75 \columnwidth.

In my typesetted result, the table has roughly 20 cm width on a a4 
landscape page (which has 30cm of width). 

Concerning the current 0.97^n factor: In my case 0.97^9 = 0.76, so that's 
where my problem comes from.
Shouldn't it be possible to calculate the required spacing of the 
tabular/longtable explicitly? I remember variables like \tabcolsep.
The n columns have (n-1) inner separations, so it should be more accurate 
to compute <complete-width> - (n-1)<space-one-seaparation-needs>, and 
distribute this over all columns.
John MacFarlane schrieb am Mittwoch, 28. Oktober 2020 um 18:19:01 UTC+1:

>
> We apply a (0.97)^n "scale factor" to make room for space between
> columns, where n = the number of columns.
>
> Looks like this gives bad results when n is large. So this
> formula needs to be tweaked. Suggestions welcome. I don't
> actually remember why we (I?) chose to make the scale factor
> depend on the number of columns in this way, but it may have
> been by experimenting...I assume I tried a constant factor
> first and it didn't work.
>
> I just tried your document (using pandoc -s)
> and with the default latex template the table actually overflows
> the textwidth. I assume you're using very wide margins or a very
> small font?
>
> Even with 1 inch margins and 10pt font, the table takes up
> nearly the whole textwidth and the contents are too wide for
> the cells. Only in landscape mode can I make it fit --
> and then it actually looks pretty good, except for one
> overlapping cell.
>
> Relevant code is around l.854 of the LaTeX writer.
>
> "'Oliver Demetz' via pandoc-discuss"
> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:
>
> > 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-discus...-/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
> .
>

-- 
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/cecc57bd-2768-4124-962e-bb5f835cfd95n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: John MacFarlane @ 2020-10-29 17:23 UTC (permalink / raw)
  To: 'Oliver Demetz' via pandoc-discuss, pandoc-discuss

"'Oliver Demetz' via pandoc-discuss"
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:

> Thanks for your reply. 
>
> Yes I am typesetting this in landscape. However, in any page orientation, 
> the minipages only occupy 0.75 \columnwidth.

Yes.  But this sum NEEDS to be less than columnwidth because of
spaces between columns.

> In my typesetted result, the table has roughly 20 cm width on a a4 
> landscape page (which has 30cm of width). 
>
> Concerning the current 0.97^n factor: In my case 0.97^9 = 0.76, so that's 
> where my problem comes from.
> Shouldn't it be possible to calculate the required spacing of the 
> tabular/longtable explicitly? I remember variables like \tabcolsep.

Well, LaTeX could calculate this, because it knows the settings
of such variables.  Pandoc doesn't. Can we specify minipage width as
{0.17\textwidth - \tablecolsep}?  That could work; I'm going to
try it.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: John MacFarlane @ 2020-10-29 18:31 UTC (permalink / raw)
  To: 'Oliver Demetz' via pandoc-discuss, pandoc-discuss

John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> "'Oliver Demetz' via pandoc-discuss"
> <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:
>
>> Thanks for your reply. 
>>
>> Yes I am typesetting this in landscape. However, in any page orientation, 
>> the minipages only occupy 0.75 \columnwidth.
>
> Yes.  But this sum NEEDS to be less than columnwidth because of
> spaces between columns.
>
>> In my typesetted result, the table has roughly 20 cm width on a a4 
>> landscape page (which has 30cm of width). 
>>
>> Concerning the current 0.97^n factor: In my case 0.97^9 = 0.76, so that's 
>> where my problem comes from.
>> Shouldn't it be possible to calculate the required spacing of the 
>> tabular/longtable explicitly? I remember variables like \tabcolsep.
>
> Well, LaTeX could calculate this, because it knows the settings
> of such variables.  Pandoc doesn't. Can we specify minipage width as
> {0.17\textwidth - \tablecolsep}?  That could work; I'm going to
> try it.

I tried this.  It almost works.  You need the latex calc package
for this.  For a 5-column table I set widths like this;

\begin{minipage}[t]{\columnwidth - 4\tabcolsep) * \real{0.15}}

That should be correct, but it gives a table that is still a
bit wider than the columnwidth.  So somewhere there is space
inserted beyond just the tabcolsep, I guess. Does anybody know
how to calculate the correct number?



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: John MacFarlane @ 2020-10-29 18:54 UTC (permalink / raw)
  To: 'Oliver Demetz' via pandoc-discuss, pandoc-discuss

John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> I tried this.  It almost works.  You need the latex calc package
> for this.  For a 5-column table I set widths like this;
>
> \begin{minipage}[t]{\columnwidth - 4\tabcolsep) * \real{0.15}}
>
> That should be correct, but it gives a table that is still a
> bit wider than the columnwidth.  So somewhere there is space
> inserted beyond just the tabcolsep, I guess. Does anybody know
> how to calculate the correct number?

Think I figured it out.
https://tex.stackexchange.com/questions/425228/cant-properly-calculate-column-width
"By default each column is surrounded by one \tabcolsep on each
side (resulting in two such spaces when two columns are side by
side)."

We suppress the seps on the edges, so we should have
2(n-1) tabcolseps in all where n is the number of columns.

This works! I will make the change.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [not found] ` <848a5b18-0f4a-482e-ba35-d3af80f2a2aan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-10-28 17:18   ` John MacFarlane
@ 2020-10-29 19:24   ` BPJ
       [not found]     ` <CADAJKhCO9SFYvP9_Xg_NQe4NjHY8f-Xz6BJJy9CFY9ynvFzn-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 17+ messages in thread
From: BPJ @ 2020-10-29 19:24 UTC (permalink / raw)
  To: pandoc-discuss

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

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/CADAJKhCO9SFYvP9_Xg_NQe4NjHY8f-Xz6BJJy9CFY9ynvFzn-g%40mail.gmail.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [not found]     ` <CADAJKhCO9SFYvP9_Xg_NQe4NjHY8f-Xz6BJJy9CFY9ynvFzn-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-10-29 19:31       ` BPJ
       [not found]         ` <CADAJKhCb2bYQdYd4W_0b2703T8f96SHe4tYBVJDkofZ1Z1pr7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: BPJ @ 2020-10-29 19:31 UTC (permalink / raw)
  To: pandoc-discuss


[-- 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 --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: 'Oliver Demetz' via pandoc-discuss @ 2020-10-29 19:40 UTC (permalink / raw)
  To: pandoc-discuss


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

This is incredible! 

Two questions:
1. how is this filter applied? To every table? Could I tweak it to just be 
applied to tables with more than, say, 6 columns?
2. If I predefine my relative column widths using a <colgroup>, then I 
think the result is always a complex table, right? So in this case, I 
cannot use this approach?

Thank you both, BPJ and John, you are just great!

BP schrieb am Donnerstag, 29. Oktober 2020 um 20:32:16 UTC+1:

> I forgot the attachment!
>
> -- 
> Better --help|less than helpless
>
> Den tors 29 okt. 2020 20:24BPJ <mel...-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-...-/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-discus...-/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/78d5fb66-4211-47b3-97b1-e8402b8e243dn%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: BPJ @ 2020-10-29 19:56 UTC (permalink / raw)
  To: pandoc-discuss

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

Den tors 29 okt. 2020 20:41'Oliver Demetz' via pandoc-discuss <
pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev:

> This is incredible!
>
> Two questions:
> 1. how is this filter applied? To every table?
>

Currently yes.

Could I tweak it to just be applied to tables with more than, say, 6
> columns?
>

Absolutely. Just below the line with the to_simple_table() conversion add
this:

``````lua
-- Check how many columns there are.
if #simple.widths < 7 then return nil end
``````

with 7 adjusted as needed

2. If I predefine my relative column widths using a <colgroup>, then I
> think the result is always a complex table, right? So in this case, I
> cannot use this approach?
>

I don't know. Possibly the conversion function just throws out what doesn't
fit. I think Albert can answer that.
The approach *can* probably be used with complex tables, but that would be
considerably more hairy, and I haven't got figured it out yet.


> Thank you both, BPJ and John, you are just great!
>

Just using such tricks as I have accumulated over the years.

BTW you can now do the header-slanting trick with CSS!


> BP schrieb am Donnerstag, 29. Oktober 2020 um 20:32:16 UTC+1:
>
>> I forgot the attachment!
>>
>> --
>> Better --help|less than helpless
>>
>> Den tors 29 okt. 2020 20:24BPJ <mel...-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-...-/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-discus...-/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/78d5fb66-4211-47b3-97b1-e8402b8e243dn%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/78d5fb66-4211-47b3-97b1-e8402b8e243dn%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/CADAJKhBWnr54SSbjoKHV8bqRkfkD7gKX2kkrLXUjT4Twfgy9Qw%40mail.gmail.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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-30 15:29                   ` Albert Krewinkel
  1 sibling, 1 reply; 17+ messages in thread
From: 'Oliver Demetz' via pandoc-discuss @ 2020-10-29 20:11 UTC (permalink / raw)
  To: pandoc-discuss


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

I could not find this CSS thing it in the docs,  can you point me to where 
I find this?

BP schrieb am Donnerstag, 29. Oktober 2020 um 20:56:22 UTC+1:

> Den tors 29 okt. 2020 20:41'Oliver Demetz' via pandoc-discuss <
> pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev:
>
>> This is incredible! 
>>
>> Two questions:
>> 1. how is this filter applied? To every table?
>>
>
> Currently yes.
>
> Could I tweak it to just be applied to tables with more than, say, 6 
>> columns?
>>
>
> Absolutely. Just below the line with the to_simple_table() conversion add 
> this:
>
> ``````lua
> -- Check how many columns there are.
> if #simple.widths < 7 then return nil end
> ``````
>
> with 7 adjusted as needed
>
> 2. If I predefine my relative column widths using a <colgroup>, then I 
>> think the result is always a complex table, right? So in this case, I 
>> cannot use this approach?
>>
>
> I don't know. Possibly the conversion function just throws out what 
> doesn't fit. I think Albert can answer that.
> The approach *can* probably be used with complex tables, but that would be 
> considerably more hairy, and I haven't got figured it out yet.
>
>
>> Thank you both, BPJ and John, you are just great!
>>
>
> Just using such tricks as I have accumulated over the years.
>
> BTW you can now do the header-slanting trick with CSS!
>
>
>> BP schrieb am Donnerstag, 29. Oktober 2020 um 20:32:16 UTC+1:
>>
>>> I forgot the attachment!
>>>
>>> -- 
>>> Better --help|less than helpless
>>>
>>> Den tors 29 okt. 2020 20:24BPJ <mel...-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-...-/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-discus...-/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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/78d5fb66-4211-47b3-97b1-e8402b8e243dn%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/78d5fb66-4211-47b3-97b1-e8402b8e243dn%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/07d2b48b-e6b9-418a-b116-fdea9b92ae0bn%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: BPJ @ 2020-10-29 20:33 UTC (permalink / raw)
  To: pandoc-discuss

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

Den tors 29 okt. 2020 21:11'Oliver Demetz' via pandoc-discuss <
pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev:

> I could not find this CSS thing it in the docs,  can you point me to where
> I find this?
>

It's just some CSS using rotate(-60), some negative padding and some extra
padding at the top of the table to make room for the rotated text, and of
course a similar filter to inject spans with classes.
I have it on my work computer. I will post it as soon as I have started
that computer tomorrow.


> BP schrieb am Donnerstag, 29. Oktober 2020 um 20:56:22 UTC+1:
>
>> Den tors 29 okt. 2020 20:41'Oliver Demetz' via pandoc-discuss <
>> pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev:
>>
>>> This is incredible!
>>>
>>> Two questions:
>>> 1. how is this filter applied? To every table?
>>>
>>
>> Currently yes.
>>
>> Could I tweak it to just be applied to tables with more than, say, 6
>>> columns?
>>>
>>
>> Absolutely. Just below the line with the to_simple_table() conversion add
>> this:
>>
>> ``````lua
>> -- Check how many columns there are.
>> if #simple.widths < 7 then return nil end
>> ``````
>>
>> with 7 adjusted as needed
>>
>> 2. If I predefine my relative column widths using a <colgroup>, then I
>>> think the result is always a complex table, right? So in this case, I
>>> cannot use this approach?
>>>
>>
>> I don't know. Possibly the conversion function just throws out what
>> doesn't fit. I think Albert can answer that.
>> The approach *can* probably be used with complex tables, but that would
>> be considerably more hairy, and I haven't got figured it out yet.
>>
>>
>>> Thank you both, BPJ and John, you are just great!
>>>
>>
>> Just using such tricks as I have accumulated over the years.
>>
>> BTW you can now do the header-slanting trick with CSS!
>>
>>
>>> BP schrieb am Donnerstag, 29. Oktober 2020 um 20:32:16 UTC+1:
>>>
>>>> I forgot the attachment!
>>>>
>>>> --
>>>> Better --help|less than helpless
>>>>
>>>> Den tors 29 okt. 2020 20:24BPJ <mel...-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-...-/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-discus...-/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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pandoc-discuss/78d5fb66-4211-47b3-97b1-e8402b8e243dn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/78d5fb66-4211-47b3-97b1-e8402b8e243dn%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/07d2b48b-e6b9-418a-b116-fdea9b92ae0bn%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/07d2b48b-e6b9-418a-b116-fdea9b92ae0bn%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/CADAJKhCi9r1XWV1J3cydLDy_vmkR_1yWZtimgZRTxCSdAO%2Brcg%40mail.gmail.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [not found]                 ` <CADAJKhBWnr54SSbjoKHV8bqRkfkD7gKX2kkrLXUjT4Twfgy9Qw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2020-10-29 20:11                   ` 'Oliver Demetz' via pandoc-discuss
@ 2020-10-30 15:29                   ` Albert Krewinkel
       [not found]                     ` <87sg9vlokd.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  1 sibling, 1 reply; 17+ messages in thread
From: Albert Krewinkel @ 2020-10-30 15:29 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


BPJ writes:

> Den tors 29 okt. 2020 20:41'Oliver Demetz' via pandoc-discuss skrev:
>
> 2. If I predefine my relative column widths using a <colgroup>, then I
>> think the result is always a complex table, right? So in this case, I
>> cannot use this approach?
>
> I don't know. Possibly the conversion function just throws out what doesn't
> fit. I think Albert can answer that.
> The approach *can* probably be used with complex tables, but that would be
> considerably more hairy, and I haven't got figured it out yet.

Right. Internally, all tables are complex tables. What `to_simple_table`
does is to call the same function that pandoc uses internally when
rendering output in formats which don't support complex tables. So some
info like colspans will be lost, but most info should make it through.
Relative column width should be retained fine.

Extremely cool filter btw! I wish I had known about this two months ago
when I was fighting to format tables in LaTeX.


--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [not found]                         ` <CADAJKhCi9r1XWV1J3cydLDy_vmkR_1yWZtimgZRTxCSdAO+rcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-10-30 15:51                           ` BPJ
  0 siblings, 0 replies; 17+ messages in thread
From: BPJ @ 2020-10-30 15:51 UTC (permalink / raw)
  To: pandoc-discuss

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

On 2020-10-29 21:33, BPJ wrote:
> Den tors 29 okt. 2020 21:11'Oliver Demetz' via pandoc-discuss <
> pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev:
> 
>> I could not find this CSS thing it in the docs,  can you point me to where
>> I find this?
>>
> It's just some CSS using rotate(-60), some negative padding and some extra
> padding at the top of the table to make room for the rotated text, and of
> course a similar filter to inject spans with classes.
> I have it on my work computer. I will post it as soon as I have started
> that computer tomorrow.
> 
> 

See the attached files.  Of course getting it to *really* work was 
harder than I remembered...

/bpj

-- 
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/33efccd0-2bbf-a0af-4b26-3b3edb17e098%40gmail.com.

[-- Attachment #2: test.html --]
[-- Type: text/html, Size: 2844 bytes --]

[-- Attachment #3: rotate-tab-heads.css --]
[-- Type: text/css, Size: 1750 bytes --]

table {
  border-collapse: collapse;
}

table th {
  font-weight: normal;
  border-bottom: 1px solid black;
}

div.rotate-table-headers {
  /************************************************************
    We need to set a padding above the table to make room
    for the rotated headers.

    Unfortunately the right amount of padding-top depends
    on the actual width of the widest column header text,
    so if possible you probably want to hard code a class/id
    or even a style attribute on the wrapping div and set the
    padding based on that.

    For the Pandoc filter solution I currently heuristically
    calculate a padding in ems from on the number of chars
    in the widest column header multiplied by a (fraction)
    factor and set a padding in a style attribute based on
    that. The factor can be modified by setting the metadata
    field `rotate_tab_heads_padding_factor` or the environment
    variable `PDC_ROTATE_TAB_HEADS_PADDING_FACTOR` to the
    desired factor. Not ideal but it works reasonably well
   ************************************************************/

  /* padding-top: 5em; */

  /* Uncomment to see box placement! *!
  /* border: 1px solid purple; */
}

div.rotate-table-headers table th span.rot {
  font-size: 0.85em;
  display: inline-block;
  white-space: nowrap;
  padding: 0;
  transform-origin: top left;
  transform: translateY(90%) rotate(-60deg);
  text-align: left !important;
  vertical-align: top;
  max-width: 3em;
  height: 1em;

  /* Uncomment to see box placement! *!
  /* border: 1px solid red; */
}

div.rotate-table-headers table th {
  padding: 0;
  max-height: 0.85em;
  text-align: left !important;

  /* Uncomment to see box placement! *!
  /* border: 1px solid blue; */
}


[-- Attachment #4: rotate-tab-heads.lua --]
[-- Type: text/x-lua, Size: 1677 bytes --]

local padding_factor = 0.35

local function tab_heads (tab)
  -- Convert the complex Table into a SimpleTable
  local simple = pandoc.utils.to_simple_table(tab)
  -- Check how many columns we got
  if #simple.widths < 7 then return nil end
  -- Reset column widths
  for i=1, #simple.widths do
    simple.widths[i] = 0.0
  end
  local widest_head = 0
  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
        -- Get the width in UTF-8 chars
        -- TODO: ignore combining marks?
        local width = pandoc.text.len(pandoc.utils.stringify(head[1]))
        -- Update the max width as needed
        if width > widest_head then widest_head = width end
        -- Insert the span
        head[1].content = {pandoc.Span(head[1].content, {class = "rot"})}
      end
    end
  end
  tab = pandoc.utils.from_simple_table(simple)
  local style = ("padding-top: %.02fem;"):format(
    (padding_factor * widest_head)
  )
  return pandoc.Div(tab, {class="rotate-table-headers", style=style})
end

local function get_config (meta)
  local factor = meta.rotate_tab_heads_padding_factor
    or os.getenv'PDC_ROTATE_TAB_HEADS_PADDING_FACTOR'
  if nil == factor then return nil end
  if 'table' == type(factor) then
    factor = pandoc.utils.stringify(factor)
  end
  padding_factor = assert(
    tonumber(factor),
    "Expected meta.rotate_tab_heads_padding_factor \z
    or PDC_ROTATE_TAB_HEADS_PADDING_FACTOR to be number"
  )
  return nil
end

return {
  { Meta = get_config },
  { Table = tab_heads },
}


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [not found]                     ` <87sg9vlokd.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2020-10-30 20:04                       ` BPJ
  0 siblings, 0 replies; 17+ messages in thread
From: BPJ @ 2020-10-30 20:04 UTC (permalink / raw)
  To: pandoc-discuss

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

Den fre 30 okt. 2020 16:30Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
skrev:

>
> BPJ writes:
>
> > Den tors 29 okt. 2020 20:41'Oliver Demetz' via pandoc-discuss skrev:
> >
> > 2. If I predefine my relative column widths using a <colgroup>, then I
> >> think the result is always a complex table, right? So in this case, I
> >> cannot use this approach?
> >
> > I don't know. Possibly the conversion function just throws out what
> doesn't
> > fit. I think Albert can answer that.
> > The approach *can* probably be used with complex tables, but that would
> be
> > considerably more hairy, and I haven't got figured it out yet.
>
> Right. Internally, all tables are complex tables. What `to_simple_table`
> does is to call the same function that pandoc uses internally when
> rendering output in formats which don't support complex tables. So some
> info like colspans will be lost, but most info should make it through.
> Relative column width should be retained fine.
>

So what happens when there is colspan/rowspan, do you get rows which are
shorter than the overall number of columns (which I think Pandoc used to
barf at) or are empty cells inserted to compensate? Back in the day I wrote
a Perl script which inserted empty cells like that before feeding HTML
tables to Pandoc. It was kind of tricky to keep track of rowspans. I did
two passes over the rows; one to splice in empty cells to compensate for
colspans, with rowspans copied from the original cells, then another to
splice in empty cells in the rows below for cells which had rowspan.
Something like

``````perl
for my $r (0 .. @$rows) {    # row index
    for my $c ( 0 .. $#{$rows->[$r]}) {    # col index
        my $cell = $rows->[$r][$c];
        next unless $cell->{rowspan};
        my $clone = {%$cell};
        $clone->{rowspan} = $cell->{rowspan} - 1;
        splice @{$rows->[$r+1]}, $c, 0, $clone;
    }
}
``````

Kind of hairy!



> Extremely cool filter btw! I wish I had known about this two months ago
> when I was fighting to format tables in LaTeX.
>

Thanks! It seems LaTeX injection has become my specialty.

/bpj

-- 
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/CADAJKhB7bZTGr4%3DjHHVg_vZnxSJMsZ56aiO24TKod1vSF%2BU8%3DQ%40mail.gmail.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [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>
  0 siblings, 1 reply; 17+ messages in thread
From: 'Oliver Demetz' via pandoc-discuss @ 2020-11-02 16:16 UTC (permalink / raw)
  To: pandoc-discuss


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

Dear John,
you said you'd make the change. I could not find a corresponding commit on 
github. So have you done it already or may I kindly remember you to realize 
this change? It would be of great help for me! 

I am very grateful for your efforts.

Thanks!


John MacFarlane schrieb am Donnerstag, 29. Oktober 2020 um 19:54:24 UTC+1:

> John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
>
> > I tried this. It almost works. You need the latex calc package
> > for this. For a 5-column table I set widths like this;
> >
> > \begin{minipage}[t]{\columnwidth - 4\tabcolsep) * \real{0.15}}
> >
> > That should be correct, but it gives a table that is still a
> > bit wider than the columnwidth. So somewhere there is space
> > inserted beyond just the tabcolsep, I guess. Does anybody know
> > how to calculate the correct number?
>
> Think I figured it out.
>
> https://tex.stackexchange.com/questions/425228/cant-properly-calculate-column-width
> "By default each column is surrounded by one \tabcolsep on each
> side (resulting in two such spaces when two columns are side by
> side)."
>
> We suppress the seps on the edges, so we should have
> 2(n-1) tabcolseps in all where n is the number of columns.
>
> This works! I will make the change.
>

-- 
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/e6e8f94d-0e94-4f6d-b03c-2325494177b8n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: HTML to latex: Controlling table column width
       [not found]                         ` <e6e8f94d-0e94-4f6d-b03c-2325494177b8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-11-02 16:37                           ` Albert Krewinkel
  0 siblings, 0 replies; 17+ messages in thread
From: Albert Krewinkel @ 2020-11-02 16:37 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


'Oliver Demetz' via pandoc-discuss writes:

> Dear John,
> you said you'd make the change. I could not find a corresponding commit on
> github. So have you done it already or may I kindly remember you to realize
> this change? It would be of great help for me!

You might have missed
https://github.com/jgm/pandoc/commit/bd7c9eb32be7c5499f4a50cb4b5f138f9eb919e8
commited on Oct 29.

--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-11-02 16:37 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 12:01 HTML to latex: Controlling table column width '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
     [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

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).