1

I want a PDF page to fit a logic puzzle completely (cropped), but I do not know the resulting width when beginning the block for the puzzle:

\documentclass[border=50px]{standalone}
\usepackage[german]{babel}
\usepackage{logicpuzzle}
\begin{document}
  \begin{fourwinds}[rows=50,columns=50,width=750px,scale=0.5]
    \framepuzzle
    \fourwindscell{1}{1}{2}{}
    \fourwindscell{50}{50}{2}{}
  \end{fourwinds}
\end{document}

I want to calculate the width 750px dynamically. The documentation of logicpuzzle says this is the width of the minipage which will surround the puzzle. But I did not found an option to set the width of a minipage dynamically.

Is there a way of adjusting the width of a minibox after it has been "created" to a new width? And can I get the width of a minipage which describes how much pixels would be needed to display the whole content?

It is possible to calculate the resulting width before creating the puzzle like width=<number of columns * width of one column>? And it is possible to get the width of one column from the logicpuzzle package?

I could not find a varwidth option for the logicpuzzle package which would be exactly what I need...

2
  • What do you mean by “calculate the width 750px” dynamically? Pixel means nothing in TeX's world.
    – egreg
    Commented Jul 10, 2017 at 20:33
  • If I change the puzzle size I have to change the width of the minipage to, but how do I know that 750px would be enough to contain the content? I want the PDF page to shrink to the puzzle size, but the PDF page shrinks currently to the size of the minipage which is a fixed size..
    – m13r
    Commented Jul 11, 2017 at 7:37

1 Answer 1

3

logicpuzzle does not offer a possibilty to define an exact width or height of a puzzle, as the actual size of the puzzle can always overshoot the given width of the minipage! But you can of course always use \resizebox to define the width or height of an object!

\documentclass{article}
\usepackage[german]{babel}
\usepackage{logicpuzzle}
\begin{document}
  \resizebox{8cm}{!}
  {
    \begin{fourwinds}[rows=50,columns=50,width=10cm,scale=0.2,fontsize=tiny]
      \framepuzzle
      \fourwindscell{1}{1}{2}{}
      \fourwindscell{50}{50}{2}{}
    \end{fourwinds}
  }
\end{document}

mwe image

As egreg already noted, 750 px (Pixel) does not make any sense in context of a vector format like PDF, so simply specify a with in cm or any other LaTeX unit.

The standard width of a column is 1 cm. Therefore you can approximately calculate the width of the puzzle with columns * 1cm * scale, e.g. 50*1cm*0.2 = 10cm! In the log you will find, that 10cm is a bit too small: Overfull \hbox (4.37386pt too wide) in paragraph at lines 12--12 [][]

Bear in mind, that using \resizebox all over the place might result in different font sizes in the puzzles, which might not look very pleasant! Using a fixed set of fontsize and scale might be the best option, but maybe difficult for puzzles with hugely different sizes.

1
  • The information about one column having a width of 1 cm is exactly what I needed! Now I can calculate the width of the puzzle. Thanks!
    – m13r
    Commented Jul 12, 2017 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .