aiorazabala / qmethod

R package to analyse Q methodology data
GNU General Public License v2.0
34 stars 18 forks source link

make \includegraphics[height = ...] respect cell height #322

Closed VerenaHeld closed 8 years ago

VerenaHeld commented 8 years ago

there's no equivalent for the \lineheight, so currently the size of images as per #296 only scales based on the width of the cell.

Will have to figure out a measurement that scales image to maximum cell height depending on template.

maxheld83 commented 8 years ago

yup, I don't know how to solve that either @VerenaKasztantowicz  – would you mind putting this on tex.stackexchange.com?

Maybe someone has an idea.

(I guess implementing the whole thing via minipages would have avoided this, but caused other problems).

maxheld83 commented 8 years ago

I guess unless we do find a \lineheight argument somewhere in TeX, that yields the respective cell height, we have to go another way. Seems almost unlikely that this would exist, because TeX is of course meant to scale cell heights as necessary; they're not supposed to be fixed height. (For that, I suppose, there's stuff like the minipage environment, which we're not using, for better or for worse -> https://github.com/aiorazabala/qmethod/issues/330).

Maybe there is a relatively easy/elegant way to do this:

if (template = "AverayZweck...Rnw") {
  height <- 30mm - 2mm  # minus some margin, to be safe
}
# switch would be the better here than lots of if clauses obviously

Then we just pass that to that paste() part as \imageheight or whatever, and we're done.

I think I initially overthought this, was afraid we'd have to add another argument, but that seems unecessary.

VerenaHeld commented 8 years ago

thank's for adding it @maxheld83!

maxheld83 commented 8 years ago

need sth like this in the beginning, then paste it later:

# Prepare Vars =============
  # ATTENTION: this cell height has to be assigned for EVERY template
  switch(paper.format,
    "AveryZweckformC32010.Rnw" = {cellheight <- 54-4},  #
    "2x2a4.Rnw" = {cellheight <- 130-4}
  )
  cellheight <- paste0(cellheight, "mm")  # latex needs this in mm
maxheld83 commented 8 years ago

@VerenaKasztantowicz I added the above fix – can you try this with your use case whether this works as expected? (works for me, but I don't have your real usecase)

VerenaHeld commented 8 years ago

works for me :) @maxheld83