2010-08-02 8 views
5

का उपयोग करके ग्रेड-राउंड बॉक्स को कैसे बनाया जाए यह एक अनुवर्ती प्रश्न है here पूछा गया। मैं के रूप में दिखाया गया है एक गोल धूसर हो जाता बॉक्स बनाने की जरूरत है।टिक्स

http://img707.imageshack.us/img707/9705/screenshot20100718at913.png

जवाब के आधार पर, मैं कुछ करने की कोशिश की, लेकिन इतना उपयोगी नहीं। तो, एक और सवाल आ रहा है।

मैं निम्नलिखित आदेश के साथ आया, लेकिन यह काम नहीं करता है। शब्दशः minipage अंदर संकलन नहीं है।

 
\newcommand{\graybox}[1]{% 
\noindent\begin{tikzpicture}% 
    \draw node[draw=black,fill=black!10,rounded corners,inner sep=2ex,text width=\mytikzwidth] {% 
    #1 
    };% 
\end{tikzpicture}% 
}% 

%% ERROR - verbatim doesn't work. 
\graybox{% 
\begin{minipage}[b]{\mytikzwidth} 
... 
\begin{verbatim} 
java -cp \$CLOJUREJAR:\$CLASSPATH clojure.lang.Script \$1 
\end{verbatim} 
... 
\end{minipage} 
} 

मैंने पर्यावरण के साथ भी प्रयास किया, जो काम नहीं करता है। minipage minipage अंदर बैठने के लिए नहीं है।

 
\newenvironment{grayboxx}% 
{\noindent\begin{tikzpicture}% 
    \draw node[draw=black,fill=black!10,rounded corners,inner 
    sep=2ex,text width=\mytikzwidth] {% 
}% 
{};% 
\end{tikzpicture}% 
} 

प्रश्न

  • क्या LaTeX कोड के साथ गलत क्या है? मैं कैसे tikzpicture में minipage साथ शब्दशः वातावरण का उपयोग कर सकते हैं?
  • तुम मुझे के रूप में संलग्न चित्र में दिखाया गया है grayboxed पर्यावरण को लागू करने के लिए एक बेहतर तरीका सिखाना सकते हैं?

यह पूरा कोड है, और मैंने संकलित परिणाम के साथ संकलित परिणाम संलग्न किया है।

http://a.imageshack.us/img571/7828/screenshot20100802at148.png

 
\documentclass{article} 

\usepackage{tikz} 

\newlength{\mytikzwidth} 
\setlength{\mytikzwidth}{\textwidth} 
\addtolength{\mytikzwidth}{-4ex} % this 10ex is just rule of thumb. 

\newcommand{\graybox}[1]{% 
\noindent\begin{tikzpicture}% 
    \draw node[draw=black,fill=black!10,rounded corners,inner sep=2ex,text width=\mytikzwidth] {% 
    #1 
    };% 
\end{tikzpicture}% 
}% 

\newenvironment{grayboxx}% 
{\noindent\begin{tikzpicture}% 
    \draw node[draw=black,fill=black!10,rounded corners,inner 
    sep=2ex,text width=\mytikzwidth] {% 
}% 
{};% 
\end{tikzpicture}% 
} 

\begin{document} 

%%%% CASE 1 - OK 
\begin{minipage}[b]{\mytikzwidth} 
clj command is as follows. 

\begin{verbatim} 
java -cp \$CLOJUREJAR:\$CLASSPATH clojure.lang.Script \$1 
\end{verbatim} 

hello.clj needs a namespace (ns) to let the modules know about this code. 
\end{minipage} 

%%%% CASE 2 - not working with verbatim 
\graybox{% 
\begin{minipage}[b]{\mytikzwidth} 
clj command is as follows. 

%\begin{verbatim} 
java -cp \$CLOJUREJAR:\$CLASSPATH clojure.lang.Script \$1 
%\end{verbatim} 

hello.clj needs a namespace (ns) to let the modules know about this code. 
\end{minipage} 
} 

%%%% CASE 3 - not inside the tikz 
\begin{grayboxx} 
\begin{minipage}[b]{\mytikzwidth} 
clj command is as follows. 

%\begin{verbatim} 
java -cp \$CLOJUREJAR:\$CLASSPATH clojure.lang.Script \$1 
%\end{verbatim} 

hello.clj needs a namespace (ns) to let the modules know about this code. 
\end{minipage} 
\end{grayboxx} 

\end{document} 

उत्तर

5

मैं LaTeX Community के लिए एक ही प्रश्न पूछा, और मैं Juanjo से निम्नलिखित जवाब मिला है।

http://a.imageshack.us/img821/290/screenshot20100802at706.png

 
\documentclass[a4paper]{article} 

\usepackage{tikz} 
\usepackage{lipsum} 

\newlength{\RoundedBoxWidth} 
\newsavebox{\GrayRoundedBox} 
\newenvironment{GrayBox}[1][\dimexpr\textwidth-4.5ex]% 
    {\setlength{\RoundedBoxWidth}{\dimexpr#1} 
    \begin{lrbox}{\GrayRoundedBox} 
     \begin{minipage}{\RoundedBoxWidth}}% 
    { \end{minipage} 
    \end{lrbox} 
    \begin{center} 
    \begin{tikzpicture}% 
     \draw node[draw=black,fill=black!10,rounded corners,% 
      inner sep=2ex,text width=\RoundedBoxWidth]% 
      {\usebox{\GrayRoundedBox}}; 
    \end{tikzpicture} 
    \end{center}} 

\begin{document} 

\lipsum[1] 

\begin{GrayBox} 
    clj command is as follows. 
    \begin{verbatim} 
    java -cp \$CLOJUREJAR:\$CLASSPATH clojure.lang.Script \$1 
    \end{verbatim} 
    hello.clj needs a namespace (ns) to let the modules 
    know about this code. 
\end{GrayBox} 

\lipsum[2] 

\begin{GrayBox}[0.75\textwidth] 
    clj command is as follows. 
    \begin{verbatim} 
    java -cp \$CLOJUREJAR:\$CLASSPATH 
    clojure.lang.Script \$1 
    \end{verbatim} 
    hello.clj needs a namespace (ns) to let the modules 
    know about this code. 
\end{GrayBox} 

\lipsum[3] 

\end{document} 
संबंधित मुद्दे