Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am a LaTeX newbie working on creating my first custom LaTeX class. I would like to know if it's possible to define parameters for \includegraphics such as width, height, center/right align etc in the custom class, so that I don't have to retype all this for each of the image that I insert.

share|improve this question
    
\includegraphics does not provide center or right align keys. What are you referring to specifically regarding this horizontal alignment? This may be something to do with a figure environment? –  Werner Feb 19 '13 at 7:02
    
What I meant was, is there a way to ensure that each of the image that I insert in the document is always of a particular size, and always aligned right? –  Pradeep Kumar Feb 19 '13 at 7:06
add comment

1 Answer

up vote 1 down vote accepted

In an attempt to be consistent with your way of writing, consider following the approach in Consistent typography by wrapping your desired inputs in a macro. Something like:

\newcommand{\mygraphic}[2][,]{% \mygraphic[<opt args>]{<file>}
  \includegraphics[width=\linewidth,height=50pt,#1]{#2}}%

To this you can add \centering or \raggedleft (for right alignment) or \raggedright (for left alignment), perhaps grouped, depending on the exact usage of \mygraphics.

In particular, the above definition \mygraphic[<opt args>]{<file>} takes an optional first argument where the default image width/height is \linewidth/50pt. Otherwise, you can override this with your own setting, or add other options.

share|improve this answer
    
Thanks Werner, this is what I had been looking for :) –  Pradeep Kumar Feb 19 '13 at 7:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.