title: \textwidth for multicolumn document in LaTeX?
body: <p>As this <a href="https://stackoverflow.com/questions/3275851/graying-out-texts-with-without-lines-with-latex/3275928#3275928">SO Q &amp; A</a> shows, I found that the \textwidth seems confusing. </p>
  
  <p>It's the width of text in normal case, but this variable doesn't seem to have the correct info about the width of text with multicols. </p>
  
  <p>This is a LaTeX code to print out the width of \textwidth (I copied the code from <a href="https://stackoverflow.com/questions/707934/determine-text-width-in-latex">here</a>).</p>
  
  <pre>
  \documentclass[]{article}
  \usepackage{layouts}
  \usepackage{multicol}
  
  \usepackage[left=20mm,right=20mm,top=33.95mm,bottom=33.95mm]{geometry}
  
  \begin{document}
  textwidth in cm: \printinunitsof{cm}\prntlen{\textwidth}
  
  \begin{multicols}{2}
  textwidth in cm: \printinunitsof{cm}\prntlen{\textwidth}
  \end{multicols}
  
  \end{document}
  </pre>
  
  <p>As a result, for multi column case, it's not possible to have a boxed text using \textwidth.</p>
  
  <pre>
  \begin{tikzpicture}
    \draw node[draw=black,fill=black!20,rounded corners,inner sep=2ex,text width=\textwidth] {
      Lorem ipsum dolor sit amet \dots
      };
  \end{tikzpicture}
  </pre>
  
  <p>or </p>
  
  <pre>
  \colorbox{red}{\parbox{\textwidth}{Black text on red background}}
  </pre>
  
  <ul>
  <li>How to know the real \texwidth for multi column documents?</li>
  <li>What's wrong with \linewidth? I tried the following example, but the result is not correct as is shown. The \listing environment gives me correct result.</li>
  </ul>
  
  <pre>
  
  \documentclass[]{article}
  \usepackage{layouts}
  \usepackage{multicol}
  \usepackage{tikz}
  \usepackage{color}
  \usepackage{listings}
  
  \usepackage[left=20mm,right=20mm,top=33.95mm,bottom=33.95mm]{geometry}
  
  \begin{document}
  textwidth in cm: \printinunitsof{cm}\prntlen{\textwidth}
  textwidth in cm: \printinunitsof{cm}\prntlen{\linewidth}
  
  \colorbox{darkgray}{Black text on red background}
  
  \noindent\colorbox{darkgray}{\parbox{\linewidth}{Black text on red background}}
  
  \begin{multicols}{2}
  
  
  This one is deep. Remember etaoin shrdlu? (Maybe you don't. Never mind, a bulletin on the subject is forthcoming.) Remember the Illuminati and fnord? Lorem ipsum is the same deal--one of those inscrutable phrases that just keeps turning up. Surely it means something. Surely it's invested with, you know, mysto power. Lorem ipsum, my children. So mote it be.
  
  textwidth in cm: \printinunitsof{cm}\prntlen{\textwidth}
  textwidth in cm: \printinunitsof{cm}\prntlen{\linewidth}
  
  This one is deep. Remember etaoin shrdlu? (Maybe you don't. Never mind, a bulletin on the subject is forthcoming.) Remember the Illuminati and fnord? Lorem ipsum is the same deal--one of those inscrutable phrases that just keeps turning up. Surely it means something. Surely it's invested with, you know, mysto power. Lorem ipsum, my children. So mote it be.
  
  
  \noindent\colorbox{darkgray}{Black text on red background}
  
  \noindent\colorbox{darkgray}{\parbox{\linewidth}{Black text on red background}}
  
  \noindent\begin{tikzpicture}
    \draw node[draw=black,fill=black!20,rounded corners,inner sep=2ex,text width=\linewidth] {
      Lorem ipsum dolor sit amet \dots
      };
  \end{tikzpicture}
  
  \definecolor{darkgray}{rgb}{0.95,0.95,0.95}
  \lstset{backgroundcolor=\color{darkgray}}
  \lstset{columns=fullflexible, basicstyle=\ttfamily,  basicstyle=\tiny, numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt}
  \begin{lstlisting}[frame=tb]
  (let ((buffer (url-retrieve-synchronously
             "http://tromey.com/elpa/package-install.el")))
    (save-excursion
      (set-buffer buffer)
      (goto-char (point-min))
      (re-search-forward "^$" nil 'move)  ;;$
      (eval-region (point) (point-masx))
      (kill-buffer (current-buffer))))
  \end{lstlisting}
  
  \end{multicols}
  
  \end{document}
  </pre>
  
  <p><a href="http://img571.imageshack.us/img571/1867/screenshot20100718at407.png" rel="nofollow noreferrer">http://img571.imageshack.us/img571/1867/screenshot20100718at407.png</a></p>