加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

latex 四项选择题 智能排版

(2013-01-29 08:32:38)
标签:

杂谈

分类: soft-latex-pdflatex
% *********************
% **** 四项选择题 ****
% *********************
% 用法: \choice{ }{ }{ }{ }
\newcommand{\fourch}[4]{~\hfill(\qquad)\\ \begin{tabular}{*{4}{@{}p{0.23\textwidth}}}(A)~#1 & (B)~#2 & (C)~#3 & (D)~#4\end{tabular}}
\newcommand{\twoch}[4]{~\hfill(\qquad)\\ \begin{tabular}{*{2}{@{}p{0.46\textwidth}}}(A)~#1 & (B)~#2\end{tabular}\\\begin{tabular}{*{2}{@{}p{0.46\textwidth}}}(C)~#3 & (D)~#4\end{tabular}}
\newcommand{\onech}[4]{~\hfill(\qquad)\\(A)~#1 \\ (B)~#2 \\ (C)~#3 \\ (D)~#4}
\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthch
\newlength\tabmaxwidth
\setlength\tabmaxwidth{0.96\textwidth}
\newlength\fourthtabwidth
\setlength\fourthtabwidth{0.25\textwidth}
\newlength\halftabwidth
\setlength\halftabwidth{0.5\textwidth}
\newcommand{\choice}[4]{\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}
\settowidth\widthchb{BM.#2}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\settowidth\widthchb{CM.#3}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\settowidth\widthchb{DM.#4}
\ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
\ifthenelse{\widthch<\fourthtabwidth}{\fourch{#1}{#2}{#3}{#4}}
{\ifthenelse{\widthch<\halftabwidth\and\widthch>\fourthtabwidth}{\twoch{#1}{#2}{#3}{#4}}
{\onech{#1}{#2}{#3}{#4}}}}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有