Skip to content

Commit

Permalink
[Tables] Introduction to tables
Browse files Browse the repository at this point in the history
I was using tabularray in my LaTeX template. It's gonna be difficult to work with tables in pandoc.
  • Loading branch information
yuki committed Feb 26, 2024
1 parent aa9f692 commit e444e3d
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 9 deletions.
20 changes: 20 additions & 0 deletions 2.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ A normal table:
Fila 2 b a
Fila 3 c




| Item | Price | # In stock |
|--------------|-----------|------------|
| Juicy Apples | 1.99 | *7* |
| Bananas | **1.89** | 5234 |




| Right | Left | Default | Center |
|:------|:-----|---------|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |




# Lorem ipsum {#lorem-ipsum}

El paso clásico "Lorem ipsum dolor sit amet..." se atribuye a una remixación del texto de De Finibus Bonorum et Malorum ("En los extremos del bien y del mal"), del filósofo romano Cicerón, de 45 aC. Más específicamente, se piensa que el pasaje proviene de las secciones 1.10.32 - 33 de su texto, con la parte más notable extraída a continuación:
Expand Down
21 changes: 21 additions & 0 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,27 @@ <h1 data-number="5"><span class="header-section-number">5</span> Tables</h1>
</tr>
</tbody>
</table>
<table>
<thead>
<tr class="header">
<th>Item</th>
<th>Price</th>
<th># In stock</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Juicy Apples</td>
<td>1.99</td>
<td><em>7</em></td>
</tr>
<tr class="even">
<td>Bananas</td>
<td><strong>1.89</strong></td>
<td>5234</td>
</tr>
</tbody>
</table>
</section>
<section id="lorem-ipsum" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Lorem ipsum</h1>
Expand Down
Binary file modified example.pdf
Binary file not shown.
3 changes: 2 additions & 1 deletion template/css/template.css
Original file line number Diff line number Diff line change
Expand Up @@ -550,5 +550,6 @@ dd {

th {
background-color: var(--templatecolor)!important;
color: var(--bs-white-rgb)!important;
/* color: var(--bs-white-rgb)!important; */
color: white!important;
}
117 changes: 109 additions & 8 deletions template/yuki.tex
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
$highlighting-macros$
$endif$
$if(tables)$
\usepackage{longtable,booktabs,array}
% \usepackage{longtable,booktabs,array}
% $if(multirow)$
% \usepackage{multirow}
% $endif$
Expand All @@ -331,13 +331,13 @@
% \makeatother
% $else$
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
% \usepackage{etoolbox}
% \makeatletter
% \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
% \makeatother
% % Allow footnotes in longtable head/foot
% \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
% \makesavenoteenv{longtable}
% $endif$
$endif$
% $if(graphics)$
Expand Down Expand Up @@ -959,9 +959,110 @@

\RequirePackage{blindtext}

%--------------------------------------------------------------------------
% TABLES
%--------------------------------------------------------------------------

$if(tables)$
% from: https://github.com/jgm/pandoc/issues/7475
\RequirePackage{tabularray}
\let\longtable\longtblr
\let\endlongtable\endlongtblr
\NewTblrTheme{headless}{
\DefTblrTemplate{contfoot-text}{default}{}
\DefTblrTemplate{conthead-text}{default}{}
\DefTblrTemplate{caption}{default}{}
\DefTblrTemplate{conthead}{default}{}
\DefTblrTemplate{capcont}{default}{}
}
\SetTblrOuter[longtblr]{
entry=none,
label=none,
theme=headless,
long,
}
\let\noalign\empty
\def\endlastfoot{\hspace{-2.5mm}} % compensate whitespace produced by left over \empty tokens
\let\endhead\empty
\def\toprule{\hspace{-1mm}} % compensate whitespace produced by left over \empty tokens
\let\midrule\empty
\let\bottomrule\empty
% add some optional styling
\UseTblrLibrary{varwidth}
\SetTblrInner[longtblr]{
vlines,
hlines,
rowsep=6pt,
colsep=12pt,
row{odd} = {maincolor!10},
row{1} = {bg=maincolor,fg=white,font=\bfseries},
columns = {co=1,valign=t},
}
% FIXME: hay que corregir el tema de las tablas.. pero para no perder, el tiempo, lo dejo así.
\NewTblrEnviron{yukitblr}
\SetTblrInner[yukitblr]{
vlines,
hlines,
rowsep=6pt,
colsep=12pt,
row{odd} = {maincolor!10},
row{1} = {bg=maincolor,fg=white,font=\bfseries},
cells={c,m},
% rowhead=1, %repeat head in new page
}

\SetTblrOuter[yukitblr]{
long,
label=none,
}

\NewTblrEnviron{yukitblrcol}
\SetTblrInner[yukitblrcol]{
vlines,
hlines,
hline{1}={1}{1}{0pt},
vline{1}={1}{1}{0pt},
rowsep=6pt,
colsep=12pt,
row{odd} = {maincolor!10},
row{1} = {bg=maincolor,fg=white,font=\bfseries},
column{1} = {bg=maincolor,fg=white,font=\bfseries},
cells={c,m},
cell{1}{1}={bg=white},
% rowhead=1, %repeat head in new page
}

\SetTblrOuter[yukitblrcol]{
long,
label=none,
}


\NewTblrEnviron{rubrica}
\SetTblrInner[rubrica]{
vlines,
hlines,
hline{1}={1}{1}{0pt},
vline{1}={1}{1}{0pt},
cell{1}{2}={bg=SeaGreen},
cell{1}{3}={bg=DarkSeaGreen},
cell{1}{4}={bg=SandyBrown},
cell{1}{5}={bg=Tomato},
column{1} = {bg=maincolor,fg=white,font=\bfseries},
cells={l,t},
row{1} = {font=\bfseries, c},
cell{1}{1}={bg=white},
% rowhead=1, %repeat head in new page
}

\SetTblrOuter[rubrica]{
long,
label=none,
}


$endif$



%%%%%%%%%%%%%%%%
Expand Down

0 comments on commit e444e3d

Please sign in to comment.