TransWikia.com

Alternative for intro in document class knitting patterns class

TeX - LaTeX Asked by HGBC46 on September 4, 2021

Using intro command text appears on left side and image on right.

  • Which command can i use to put the image to the left and text on the right side?

One Answer

There is no command in the knittingpattern class to put the image on the left, but you can define a new command to do that.

The intro command three arguments: the ratio of the columns (this is an optional argument with default value 0.25), the text (which is set in a tabular column of type m, which is a paragraph) and the image, which is set using a includegraphics command. The size of the first column is calculated as the textwidth minus the fraction of the textwidth as given in the optional first argument (and a small correction for the column separation).

From the source code of the class:

newcommand{intro}[3][.25]{begin{tabular}{m{textwidth - 4tabcolsep
- #1textwidth}m{#1textwidth}}
#2&fbox{includegraphics[width=#1textwidth]{#3}}
end{tabular}}

For a new command you can switch the columns and the arguments around:

newcommand{introleft}[3][.25]{begin{tabular}{m{#1textwidth}m{textwidth - 4tabcolsep
- #1textwidth}}
fbox{includegraphics[width=#1textwidth]{#2}}&#3
end{tabular}}

Note that the tabular column specifications have switched (the m{#1textwidth} column is now first), the actual columns have also switched (the includegraphics cell is now second) and the order of the arguments has switched (#2 is now the image and #3 is the text).

MWE for this modification, adapted from the package documentation:

documentclass{knittingpattern}

begin{document}

newcommand{introleft}[3][.25]{begin{tabular}{m{#1textwidth}m{textwidth - 4tabcolsep
- #1textwidth}}
fbox{includegraphics[width=#1textwidth]{#2}}&#3
end{tabular}}

introleft{lion.png}{
Introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction.
Introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction.
Introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction
introduction introduction introduction introduction introduction.
}

end{document}

Result:

enter image description here

Answered by Marijn on September 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP