VietTUG.org - old forum

id = 4325, parent = 4272, thread = 4257, catid = 17, locked = 0, moved = 0,
userid = vanchutr, ip = 117.2.41.129, time = 2008/01/18 (1200605657) ,
subject = Re:Tại sao khi vẽ bảng biến thiên bằng wintpic, hits = 0, karma = 1+0-,
Tôi xin đóng góp thêm về việc vẽ bảng biến thiên.
Ta có thể dùng gói tabvar để vẽ được bảng biến thiên.

\documentclass[12pt]{article}



\usepackage[utf8]{vietnam}

\usepackage{amssymb,amsmath,amstext}



\usepackage{pstricks}



\input tabvar




\begin{document}


\hfil

\tabvar{%

\tx{x}&\tx{-\infty}&&\txt{0}&&\tx{+\infty}\cr

\tx{x^2}&\txh{+\infty}&\fd&\txbt{0}&\fm&\txh{+\infty}\cr

\tx{x^3}&\txb{-\infty}&\fmb&\txt{0}&\fmh&\txh{+\infty}\cr}


\end{document}


Và nếu đặt test.tex là tên của file nguồn trên đây thì:
latex test -> dịch ra test.dvi ta dùng yap để xem -> hình ảnh đạt
dvips test -> dịch ra test.ps và dùng ghostview để xem -> hình ảnh đạt
ps2pdf -sPAPERSIZE#a4 test.ps test.pdf thì có test.pdf -> hình ảnh đạt

(Hiển nhiên các bạn có thể load gói tabvar từ ctan về.
Hoặc các bạn chép đoạn sau đây và ghi lại với tên tabvar.tex
%-- Macros tabvar créées par Denis Léger
\newrgbcolor{gristabvar}{0.7669 0.7669 0.7669}
\newdimen\tabdim
\newdimen\tabblanc
\catcode`\@=11
\newdimen\[email protected]
\newdimen\[email protected]
\newdimen\[email protected]
\newdimen\[email protected]
\newdimen\[email protected]
\newdimen\[email protected]
\newdimen\[email protected]
\newdimen\[email protected]
\newcount\[email protected]
\newdimen\[email protected]
\tabdim=0.8cm
\tabblanc=2pt
\newif\[email protected]
\def\psdefaut{\psset{xunit=1cm,yunit=1cm,runit=1cm,linewidth=0.4pt,linestyle=solid,linecolor=black}}
\let\dsp=\displaystyle
\let\spt=\scriptstyle
\def\initY#1{%
\setbox100=\hbox{#1}%
\global\[email protected]=\ht100\global\advance\[email protected] by\dp100}
\def\initX#1{\setbox100=\hbox{#1}%
\ifdim\wd100>\tabdim
  \global\[email protected]=\wd100
\else
  \global\[email protected]=\tabdim
\fi}
\def\initx#1{\setbox100=\hbox{#1}\global\[email protected]=\wd100}
\def\calculeYTotal{%
 \global\[email protected]=\[email protected]\global\advance\[email protected] by\[email protected]\global\advance\[email protected] by\[email protected]}
\def\setY#1#2#3{\global\[email protected]=#1\global\[email protected]=#2\global\[email protected]=#3\relax}
\def\max#1#2{\ifdim#2>#1\global#1=#2\fi}
\def\GererX#1{%
\initX{#1}\[email protected]=1.1\[email protected]%
\max{\[email protected]}{\[email protected]}}
\def\GererXDimension#1{%
\[email protected]=#1%
\t[email protected]=1.1\[email protected]%
\max{\[email protected]}{\[email protected]}%
\max{\[email protected]}{\tabdim}%
}
\def\GererDXSimple#1{%
\initX{#1}\[email protected]=1.1\[email protected]
\[email protected]=0.5\[email protected]
\max{\[email protected]}{\[email protected]}%
}
\def\GererDXDimension#1{%
\[email protected]=#1%
\max{\[email protected]}{\[email protected]}%
\max{\[email protected]}{0.5\tabdim}%
}
\def\tabvarputhaut#1{%
\[email protected]
  \initY{#1}%
  \max{\[email protected]}{\[email protected]}%
\fi
\rput(\[email protected],-0.5\[email protected]){#1}}
\def\tabvarputmilieu#1{%
\[email protected]
  \initY{#1}%
  \max{\[email protected]}{\[email protected]}%
\fi%
\[email protected]=\[email protected]\advance\[email protected] by 0.5\[email protected]
\rput(\[email protected],-\[email protected]){#1}}
\def\tabvarputbas#1{%
\[email protected]
  \initY{#1}%
  \max{\[email protected]}{\[email protected]}%
\fi%
\[email protected]=\[email protected]\advance\[email protected] by \[email protected]\advance\[email protected] by 0.5\[email protected]
\rput(\[email protected],-\[email protected]){#1}}
\def\traithaut{\psline(\[email protected],0)(\[email protected],-\[email protected])}
\def\traitmilieu{\[email protected]=\[email protected]\advance\[email protected] by\[email protected]
\psline(\[email protected],-\[email protected])(\[email protected],-\[email protected])}
\def\traitbas{\[email protected]=\[email protected]\advance\[email protected] by\[email protected]
\dimen100=\[email protected]\advance\[email protected] by\[email protected]s
\psline(\[email protected],-\dimen100)(\[email protected],-\[email protected])}
\def\doubletraithaut{\psline[doubleline=true,doublesep=1pt](\[email protected],0)(\[email protected],-\[email protected])}
\def\doubletraitmilieu{\[email protected]=\[email protected]\advance\[email protected] by\[email protected]
\psline[doubleline=true,doublesep=1pt](\[email protected],-\[email protected])(\[email protected],-\[email protected])}
\def\doubletraitbas{\[email protected]=\[email protected]\advance\[email protected] by\[email protected]
\dimen100=\[email protected]\advance\[email protected] by\[email protected]
\psline[doubleline=true,doublesep=1pt](\[email protected],-\dimen100)(\[email protected],-\[email protected])}
\def\trait{\traithaut\traitmilieu\traitbas}
\def\dbt{\doubletraithaut\doubletraitmilieu\doubletraitbas}
\def\fm{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=\[email protected]\advance\[email protected] by\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\fd{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=\[email protected]\advance\[email protected] by\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\fhh{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-0.5\[email protected])(0.9\[email protected],-0.5\[email protected])}\hfil}}
\def\fhm{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=\[email protected]\advance\[email protected] by 0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected]
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\fhb{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=\[email protected]\advance\[email protected] by\[email protected]\advance\[email protected] by0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\fmb{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=\[email protected]\advance\[email protected] by\[email protected]\advance\[email protected] by 0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by 0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\fdb{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=\[email protected]\advance\[email protected] by\[email protected]\advance\[email protected] by 0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by 0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\fmh{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=0.5\[email protected]\[email protected]=\[email protected]\advance\[email protected] by 0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\fdh{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi
\[email protected]=0.5\[email protected]\[email protected]=\[email protected]\advance\[email protected] by 0.5\[email protected]
\[email protected]=\[email protected]\advance\[email protected] by -\[email protected] %
\hbox to\[email protected]{\rput(\[email protected],0){\psline{->}(-0.9\[email protected],-\[email protected])(0.9\[email protected],-\[email protected])}\hfil}}
\def\tx#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to \[email protected]{\tabvarputmilieu{$\dsp #1$}\hfil}%
}
\def\txh#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to\[email protected]{\tabvarputhaut{$\dsp #1$}\hfil}%
}
\def\txb#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to\[email protected]{\tabvarputbas{$\dsp#1$}\hfil}%
}
\def\txt#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to\[email protected]{\traithaut\tabvarputmilieu{$\dsp #1$}\traitbas\hfil}%
}
\def\txht#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to\[email protected]{\tabvarputhaut{$\dsp #1$}\traitmilieu\traitbas\hfil}%
}
\def\txbt#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to\[email protected]{\traithaut\traitmilieu\tabvarputbas{$\dsp #1$}\hfil}%
}
\def\xt#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to\[email protected]{\tabvarputmilieu{$\dsp#1$}\traitbas\hfil}%
}
\def\xdbt#1{%
\[email protected]
  \GererX{$\dsp#1$}%
  \GererDXSimple{$\dsp#1$}%
\fi
\hbox to\[email protected]{\tabvarputmilieu{$\dsp#1$}\doubletraitbas\hfil}%
}
\def\txdbthb#1#2{%
\[email protected]
  \initY{$\dsp #1$}\max{\[email protected]}{\[email protected]}%
   \initY{$\dsp #2$}\max{\[email protected]}{\[email protected]}%
  \initx{$\dsp#1$}\advance\[email protected] by 3 pt\relax
  \GererDXDimension{\[email protected]}%
  \initx{$\dsp#1$}\max{\[email protected]}{\[email protected]}%
  \global\advance\[email protected] by 3pt\global\[email protected]=\[email protected]
  \initx{$\dsp#2$}\global\advance\[email protected] by\[email protected]
  \GererXDimension{\[email protected]}%
\fi%
\hbox to\[email protected]{%
\rput[r](\[email protected],0){\rput[r](-3pt,-0.5\[email protected]){$\dsp#1$}}%
%
\dbt
 %
 \[email protected]=\[email protected]\advance\[email protected] by \[email protected]\advance\[email protected] by 0.5\[email protected]
 \rput[l](\[email protected],0){\rput[l](3pt,-\[email protected]){$\dsp #2$}}%
 \hfil}%
}
\def\txdbthh#1#2{%
\[email protected]
  \initY{$\dsp #1$}\max{\[email protected]}{\[email protected]}%
  \initY{$\dsp #2$}\max{\[email protected]}{\[email protected]}%
  \initx{$\dsp#1$}\advance\[email protected] by 3 pt\relax
  \GererDXDimension{\[email protected]}%
  \initx{$\dsp#1$}\max{\[email protected]}{\[email protected]}%
  \global\advance\[email protected] by 3pt\global\[email protected]=\[email protected]
  \initx{$\dsp#2$}\global\advance\[email protected] by\[email protected]
  \GererXDimension{\[email protected]}%
\fi%
\hbox to\[email protected]{%
 \rput[r](\[email protected],0){\rput[r](-3pt,-0.5\[email protected]){$\dsp#1$}}%
 %
\dbt
 %
 \rput[l](\[email protected],0){\rput[l](3pt,-0.5\[email protected]){$\dsp #2$}}
 \hfil}%
}%
\def\txdbtbh#1#2{%
\[email protected]
  \initY{$\dsp #1$}\max\[email protected]\[email protected]%
  \initY{$\dsp #2$}\max\[email protected]\[email protected]%
  \initx{$\dsp#1$}\advance\[email protected] by 3 pt\relax
  \GererDXDimension{\[email protected]}%
  \initx{$\dsp#1$}\max{\[email protected]}{\[email protected]}%
  \global\advance\[email protected] by 3pt\global\[email protected]=\[email protected]
  \initx{$\dsp#2$}\global\advance\[email protected] by\[email protected]
  \GererXDimension{\[email protected]}%
\fi%
\hbox to\[email protected]{%
 \[email protected]=\[email protected]\advance\[email protected] by \[email protected]\advance\[email protected] by 0.5\[email protected]
 \rput[r](\[email protected],0){\rput[r](-3pt,-\[email protected]){$\dsp#1$}}%
 %
\dbt
 %
 \rput[l](\[email protected],0){\rput[l](3pt,-0.5\[email protected]){$\dsp #2$}}
 \hfil}%
}%
\def\txdbtbb#1#2{%
\[email protected]%
  \initY{$\dsp #1$}\max{\[email protected]}{\[email protected]}%
  \initY{$\dsp #2$}\max{\[email protected]YBas}{\[email protected]}%
  \initx{$\dsp#1$}\advance\[email protected] by 3 pt%
  \GererDXDimension{\[email protected]}%
  \initx{$\dsp#1$}\max{\[email protected]}{0.90909\[email protected]}%
  \global\advance\[email protected] by 3pt\global\[email protected]=\[email protected]%
  \initx{$\dsp#2$}\global\advance\[email protected] by\[email protected]%
  \GererXDimension{\[email protected]}%
\fi%
\hbox to\[email protected]{%
 \[email protected]=\[email protected]\advance\[email protected] by\[email protected]\advance\[email protected] by 0.5\[email protected]\relax%
 \rput[r](\[email protected],0){\rput[r](-3pt,-\[email protected]){$\dsp#1$}}%
 %
\dbt
 %
 \[email protected]=\[email protected]\advance\[email protected] by\[email protected]\advance\[email protected] by 0.5\[email protected]\relax
 \rput[l](\[email protected],0){\rput[l](3pt,-\[email protected]){$\dsp #2$}}%
 \hfil}%
}%
\def\grise{%
\[email protected]
  \GererXDimension{\tabdim}%
  \GererDXDimension{0.5\tabdim}%
\fi%
\hbox to\[email protected]{\psframe[linecolor=gristabvar,fillstyle=solid,fillcolor=gristabvar](0,0)(\[email protected],-\[email protected])\hfil}}
\toksdef\ta=0 \toksdef\tb=2
\long\def\rightappenditem#1\to#2{\ta={\\{#1}}\tb=\expandafter{#2}%
 \xdef#2{\the\tb\the\ta}}
\long\def\leftappenditem#1\to#2{\ta={\\{#1}}\tb=\expandafter{#2}%
\xdef#2{\the\ta\the\tb}}
\def\lop#1\to#2{\expandafter\lopoff#1\lopoff#1#2}
\long\def\lopoff\\#1#2\lopoff#3#4{\gdef#4{#1}\gdef#3{#2}}
\def\clearListes{\gdef\listeY{}\gdef\listeX{}\gdef\listeDX{}}
\def\savedimsY{%
  \expandafter\rightappenditem\the\[email protected]\to\listeY
  \expandafter\rightappenditem\the\[email protected]\to\listeY
  \expandafter\rightappenditem\the\[email protected]\to\listeY}
\def\litY{%
 \lop\listeY\to\a \[email protected]=\a
 \lop\listeY\to\a \[email protected]=\a
 \lop\listeY\to\a \[email protected]=\a
 \global\advance\[email protected] by 2\tabblanc
 \global\advance\[email protected] by 2\tabblanc
 \global\advance\[email protected] by 2\tabblanc
 \calculeYTotal}
\def\ajouteX#1{%
  \expandafter\rightappenditem\the #1\to\listeX}
\def\ajouteXAGauche#1{%
  \expandafter\leftappenditem\the #1\to\listeX}
\def\extraitX{\lop\listeX\to\a\[email protected]=\a}
\def\ajouteDX#1{%
  \expandafter\rightappenditem\the #1\to\listeDX}
\def\ajouteDXAGauche#1{%
  \expandafter\leftappenditem\the #1\to\listeDX}
\def\extraitDX{\lop\listeDX\to\a\[email protected]=\a}
\def\initListeXListeDX#1{%
\global\[email protected]=0
\setbox150=\vbox{\halign{%
\global\advance\[email protected] by 1
\ifnum\[email protected]=1
  \[email protected]=0pt
  \ajouteXAGauche{\[email protected]}%
  \ajouteDXAGauche{\[email protected]}%
\fi
##\hfil\vrule&&%
\hfil
\ifnum\[email protected]=1
  \[email protected]=0pt
  \ajouteXAGauche{\[email protected]}%
  \ajouteDXAGauche{\[email protected]}%
\fi
##\hfil\cr%
#1}}}
\def\TABVAR#1{%
\vbox{\vglue\smallskipamount\nobreak%
{\offinterlineskip\everycr{\noalign{\hrule}}%
\[email protected]
\else
  \litY
\fi%
\hbox{\vrule\vbox{\halign{%
\[email protected]
  \savedimsY
  \setY{0pt}{0pt}{0pt}%
\else
  \litY%
\fi
\vrule height 0pt depth \[email protected] width 0pt\extraitX\extraitDX##\ajouteX{\[email protected]}\ajouteDX{\[email protected]}%
\vrule&&%
\extraitX\extraitDX##\ajouteX{\[email protected]}\ajouteDX{\[email protected]}\cr%
#1}}\vrule}}
\[email protected]
  \savedimsY%
\fi
\medbreak%
}}
\def\tabvar#1{{\clearListes\initListeXListeDX{#1}\[email protected]%
\psset{linewidth=.4pt}%
\setbox150=\hbox{\TABVAR{#1}}\[email protected]\TABVAR{#1}}}
\catcode`\@=12
%-- Fin Macros tabvar


Bây giờ có thể thử được rồi.