nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
178 stars 18 forks source link

Easy halign formatting with borders for LaTeX? #76

Open ckraner opened 7 years ago

ckraner commented 7 years ago

Is there any way you can simplify using halign for LaTeX printing? Working from your example code, I was able to center the whole column with one line of code:

sprinkle(cols = 2, halign="center") %>%

However, when I looked at the LaTeX code, I noticed this centered the column twice.

\\multicolumn{1}{c}{\\parbox[]{49.5pt}{\\centering -0.39}} &

Now this doesn't effect me running the code at all, but seems redundant. I assume it has to do with the valign height and width options. However, to the request: I was hoping halign could be expanded to use normal latex formatting like |c| to control borders. You already have control to change it to c, and the parboxs and centerings do not hinder this.

nutterb commented 7 years ago

I honestly couldn't tell you what my reasoning here was. Well, I can, actually. It wasn't working...and then I did something...and then it was working. I haven't touched it since :)

But there's certainly room for improvement.

ckraner commented 7 years ago

I think the main focus was the parbox. Those seem to be the biggest thing that holds. However, I rescind this request, because I found a work around using the functions you have.

sprinkle(cols = 2, halign= "center", border=c("left","right"), border_thickness=.5, border_color="black")

This originally wouldn't work for me, and it turns out color and colortbl packages were not loaded in my LaTeX! Is this something that pixiedust should do, or should I get in the habit of it?

Also, you should consider changing the defaults for the borders. border_thickness=.5 was very important, otherwise one line would be .5px and the other would be 1px in the setting. In addition, everywhere that I put a line I get an error about Black because in colors it is black, hence why I added border_color="black".

nutterb commented 7 years ago

If I ever learn of a way to inject the LaTeX dependencies from pixiedust, you can be sure I will do that. I haven't researched that much at all, and have depended on my own template that starts with the header that can be copied from http://nutterb.github.io/pixiedust/latex-configuration.html (also in the package documentation). The preamble there has worked well for me.

ckraner commented 7 years ago

This fixes the issue with Black. However, IMO the border_thickness is too thick/not the standard border thickness.