1

Due to faulty representation of table lines when using colored cells (discussed in many topics e.g. here and here), I need a rasterized version of my PDF, since I have no influence on the client's PDF viewer.

I'm compiling using pdflatex. First tries using Gimp allowed me to save singular pages as a rasterized version - however, I'm looking for a (semi-)automated way to save large PDF files as a rasterized PDF.

Best case szenario would be a modification of the pdflatex options.

PSC
  • 309
  • I normally redraw the lines on top of the colors if I need a perfect result. See e.g. http://tex.stackexchange.com/questions/134263/how-to-set-tikzmarks-with-noalign-at-the-edge-of-tabular-rows. – Ulrike Fischer Apr 12 '16 at 08:00
  • Whoa fast answer. I'll have a look into that, I tried a similar approach which turned out unfeasible since I needed the exact heights of the table cells. Anyways - having the vectorized PDF with nice lines would definitely be awesome. – PSC Apr 12 '16 at 08:02
  • @Ulrike Hmm, From reading the comments, I don't see a solution for a longtable, which I am using (actually a longtabu, but that should make no difference), so the problem can only be solved partially I guess. – PSC Apr 12 '16 at 10:39
  • I redraw lines in longtables too. But it can be fiddling (in all tabulars). – Ulrike Fischer Apr 12 '16 at 10:50
  • Okay, Problem is, that I'm automatically creating tables from csv-data using pgfplotstable and while the number of columns is always the same, the number of rows differs almost always (the height of the cells as well). However, if you tell me, that your approach works once it is setup, I'll be glad to learn. – PSC Apr 12 '16 at 10:56

1 Answers1

1

It is not very difficult to redraw lines. You only need enought suitable \tikzmark/\pgfmarks -- you can create them automatically with some counter. You can even use them in tikz commands before they are set to draw backgrounds. In a setup with automatic breaks you should put the \tikz-commands inside the cells to that they don't get separated from their mark by a page break.

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tikz}
\usetikzlibrary{tikzmark}


\begin{document}

\tikz[overlay,remember picture]\fill[yellow,]  ({pic cs:tabstart} |- {pic cs:a1}) rectangle ({pic cs:tabend} |- {pic cs:a2});


\tikzmark{tabstart}%
\begin{tabular}{l}
abcxxxxxxxxxxxxxxx               \\\noalign{\pgfmark{a1}}
aa\rule[-1cm]{4pt}{2.5cm}xxxxxxxx\\\noalign{\pgfmark{a2}}
\end{tabular}%
\tikzmark{tabend}

\tikz[overlay,remember picture]\draw[red,]  ({pic cs:tabstart} |- {pic cs:a1}) --({pic cs:tabend} |- {pic cs:a1});
\tikz[overlay,remember picture]\draw[green,]({pic cs:tabstart} |- {pic cs:a2}) --({pic cs:tabend} |- {pic cs:a2});

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • okay, this solution is indeed simple. However, I cannot yet see, how it can be automated with pgfplotstable so each pgfmark can get a unique number. – PSC Apr 12 '16 at 13:26
  • Use a counter and \stepcounter{counter}\pdfmark{XXX\thecounter}. – Ulrike Fischer Apr 12 '16 at 13:34
  • (Note: I think you meant pgfmark rather than pdfmark). I'm slowly getting there. Unfortunately, inserting the pgfmark at the BEGINNING of each line (seems to me to be easier to achieve using pgfplotstable) results in messed up vertical spacing in all rows. One row looks like this \hhline {--}\stepcounter {linespgf}\pgfmark {test\thelinespgf }aaaaaa:&bbbbbb\\% so I guess, the pgfmark has some kind of size (using \noalign might fix it, but that doesn't work in my tabu-environments) – PSC Apr 12 '16 at 14:21
  • In a cell use better \tikzmark, \pgfmark doesn't start a paragraph. But in a cell the mark is on the baseline of the cell which makes it difficult to find the borders. \noalign is better as it inserts the mark between the rows. – Ulrike Fischer Apr 12 '16 at 14:26
  • I figured that \noalign would be required, so it's back to square 1 for me, this time using \noalign... – PSC Apr 12 '16 at 14:27
  • see my solution here [http://tex.stackexchange.com/questions/303895/change-default-row-separator-in-pgfplotstable-order-of-commands-for-each-line/304035#304035] – PSC Apr 13 '16 at 08:10
  • I'm still working on the abovementioned problem. I now need additional vertical lines but can only achieve the ones using the tikzmark at the table starts/ends. Is there any other way of retrieving the required horizontal positions of the vertical lines? – PSC Apr 13 '16 at 12:55
  • You can use !{\tikzmark{..}} in the tabular preamble (needs array package). Or you add marks in the begin of the cells and then shift the lines by \tabcolsep.(Avoid too many vertical lines, often this doesn't look good). – Ulrike Fischer Apr 13 '16 at 14:41
  • Perfect! Now all my tables work perfect (I didn't try longtabu, that's up next). I prefer tables with as little lines as possible, however the corporate design requires many lines and filled rows. – PSC Apr 14 '16 at 11:07
  • I just noticed another issue: I recieve a lot of Overful hbox and Missing character: There is no ; in font nullfont! errors in the log file. Adding \font\nullfont=cmr10 uncovers, that due to the tikzmark/pgfmark added in every cell, there is a hidden ; which is the reason for both abovementioned errors. While this is not a crucial error, it would be nice to have a clean file... – PSC Apr 19 '16 at 12:55
  • The missing characters are from tikz, as tikzmark essentially creates an empty picture. You can avoid them by adding some drawing command \tikzmark[\path (0,0)]{abc} or ask the tikzmark-author. No idea why you get overful boxes, perhaps some spurious spaces. – Ulrike Fischer Apr 19 '16 at 13:31
  • Interestingly only some of the Missing character errors can be resolved by using a drawing command. I think for now the result is sufficient and the cleanup of the log can be a future project. Thanks again for all the help! – PSC Apr 19 '16 at 13:46
  • I'm on it again and have run into another problem. I'm trying to add lines to my longtables (using longtabupackage). I think I'm on a good way, however - as I understand tikz - it is not possible to add the tikz-commands AFTER the table is set, since then the tikz-lines will only know the coordinates of the current page. Is there some workaround to add lines to a longtabu on other pages then the last? – PSC Apr 25 '16 at 13:46
  • Put the tikz code in the cells. Or in the header or the footer of the page. – Ulrike Fischer Apr 25 '16 at 13:49
  • Okay, this actually almost works. Only problem: when adding a tikzmark in the tabular preamble (as you suggested earlier), there is some whit space added in the respective cell. The reason for this is obviously a missing \noalign, however, when adding \noalign, the code doesn't compile anymore due to a misplaced noalign – PSC Apr 26 '16 at 09:42
  • No this is not due to a missing noalign. And this is not something you should discuss in comments. Create a new question with a sensible MWE. – Ulrike Fischer Apr 26 '16 at 09:48
  • I followed your tip and created a new topic: http://tex.stackexchange.com/questions/306404/longtabu-in-pgfplotstable-from-csv-input-with-additional-tikz-lines – PSC Apr 27 '16 at 06:39