I want to crop an image but I don't want to define how much should be croped but how much should be left. The idea is if I have a command \pic{lines=5,path=picture.jpg} I want to only show the bottom (or top) part of the picture where this part shall be 5\baselineskip high. The width shall be untouched. I want to use that in a multicolumn environment. Right now I tried the following:


\keys_define:nn {pic}
path .tl_set:N = \l_path,
lines .fp_set:N = \l_lines,

\IfNoValueF {#1} { \keys_set:nn {pic} {#1} }
\fp_set:Nn \l_lineheight {\fp_eval:n {\baselineskip*\fp_use:N \l_lines }}
\fp_set:Nn \l_picheight {\help}
\fp_compare:nNnTF {\l_lineheight}<{\l_picheight}
  \fp_set:Nn \l_help {\fp_eval:n {\l_picheight-\l_lineheight}}
  \noindent\includegraphics[trim=0 0 0 \l_help,clip]{\l_path}


Some Text

This works but only if I know how much I want to trim. Also it trims top and right as well for a reason I don't know. The condition is necessary because later I want to do something else if lines*\baselineskip exceeds the height of the picture.

1 Answer 1


Question closed: I found a solution with putting the \includegraphics[trim=0 0 0 \l_help,clip]{\l_path} outside ExplySyntaxOn/Off in a extra command.

You must log in to answer this question.

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