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 wondering how do you usually deal with figure width when you are writing a paper. (use \linewidth, \textwidth ? others?)

Maybe we can just define a "switch" and use it with ifelse package?

(Assume that you are writing a onecolumn version, and you also want to know the twocolumn layout at the same time without adjusting the \witdh manually too often.)

EDIT. LaTeX is quite "intelligent" to format the text content. Can we let it deal with figures the same way?

That is, when we add a figure, we not only just set the width=..., but also add a tag for informing LaTeX that "I am setting this width according to A4 paper twocolumn".

Then when we change the layout to onecolumn, LaTeX knows how to handle (rescale).

EDIT

\usepackage{ifthen}
\newboolean{figColumnTrueOneFalseTwo}
\setboolean{figColumnTrueOneFalseTwo}{false}
%\setboolean{figColumnTrueOneFalseTwo}{true}

% in main.tex
\ifthenelse {\boolean{figColumnTrueOneFalseTwo}}{
% for onecolumn here
}{
% for twocolumn here
}
share|improve this question
3  
Is \columnwidth what you are looking for? –  karlkoeller Sep 2 '13 at 14:56
    
@karlkoeller Oh, I've never used \columnwidth, +1. Thanks! (I am looking for suggestions, and would like to know how people usually do! :)) –  Hongying Sep 2 '13 at 15:04
    
\columnwidth or \linewidth should do what you want. –  David Carlisle Sep 2 '13 at 15:09
    
Related: tex.stackexchange.com/questions/16942/… –  egreg Sep 2 '13 at 15:27
    
Can you expalin the edit a bit better? Wasn't \includegraphics[width=\columnwidth]{...} enough? What do you need this info for? –  karlkoeller Sep 3 '13 at 8:23

1 Answer 1

As this question was solved in the comments, in order to remove from unanswered, this is a community wiki answer.

Sort answer: usually \includegraphics[width=\linewidth]{} automatically fit well in most cases.

Long answer:

Difference between \textwidth, \linewidth and \hsize (and \columnwidth) is well explained in the above link. In practice, in one column document, \textwidth,\columnwidth and \linewidth is the same length (while you are out of any special environment), so you can use any of these lengths to fix the width of the image:

\documentclass{article}
\begin {document} 
\the\textwidth   % this length is 345.0pt
\the\linewidth   % this is  also  345.0pt
\the\columnwidth % this is again  345.0pt
\end{document} 

However, if you change from one to two column, then \textwidth is more than twice the width of one column and largely inappropiate for the figures that must fit within one column:

\documentclass[twocolumn]{article}
\begin {document} 
\the\textwidth   % this is now 469.0pt
\the\linewidth   % this is now 229.5pt
\the\columnwidth % this is now 229.5pt
\end{document} 

So, one may think that, that as general rule, is safer \columnwidth, since this work in both formats. Nonetheless, in two columns documents are usual the figures extending in two columns (starred floats \begin{figure*} ...) where (one) \columnwidth is just the wrong option. Instead, \linewidth fill the space as expected in both starred and not starred floats, as well as in images without floats, in both one or two columns documents.

For images without floats and inside in some environment is not possible a general rule, but probably \linewidth is the choice in most cases. For example, in a itemize environment will be 20pt narrower that the column width, that probably is what you want for an "itemized" picture (...or may be not, it depend of what you want).

share|improve this answer

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.