TransWikia.com

Making a function to take inputs and give an output

TeX - LaTeX Asked by famakki1 on December 25, 2020

I am trying to make a function in order to have an image on the left and text on the right. I have come up with the following:

% Special container for image on left and text on right
renewcommandimtxt[3]{
begin{center}
begin{minipage}{#1} %First argument
    includegraphics{#2} %Second argument
end{minipage}quad
begin{minipage}{0.50linewidth}
#3 %Third Argument
end{minipage}
end{center}
}

I want to use this function then in my LaTeX document like so:

imtxt[2cm][Images/Icon_Test.png][test text]

So overall, it will add an image on the left which will be 2cm wide then spacing using quad and finally my text.

However, the newcommand has some problems and it doesn’t compile. Thoughts?

EDIT:

Example code:

 % Default Template and Font Size
documentclass[11pt]{extarticle}
usepackage{mwe}
 % Set Margins of the Document
usepackage[a4paper,bindingoffset=0in,left=2.54cm,right=2.54cm,top=3.8cm,bottom=2.5cm,footskip=.25in]{geometry}

% Special container for image on left and text on right
renewcommandimtxt[3]{
begin{center}
begin{minipage}{#1}
    includegraphics{#2}
end{minipage}quad
begin{minipage}{0.50linewidth}
#3
end{minipage}
end{center}
}

% Document begins here
begin{document}
imtxt{2cm}{example-image-b}{test text}
end{document}

Although from suggestion to use {} instead of [] it now works, I still get warning command imtxt undefined in Overleaf

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