LaTeX - 排版试卷 (选择题)

方法1.

\documentclass{article}
\usepackage{ifthen}
\usepackage{array}
%                    *********************
%                     **** 四项选择题 ****
%                    *********************
%      用法: \choice{ }{ }{ }{ }

\newcommand{\fourch}[4]{%~\hfill(\qquad)\\
\begin{tabular}{*{4}{@{}p{0.25\textwidth}}}(A)~#1 & (B)~#2 & (C)~#3 & (D)~#4\end{tabular}}
\newcommand{\twoch}[4]{%~\hfill(\qquad)\\
\begin{tabular}{*{2}{@{}p{0.5\textwidth}}}(A)~#1 & (B)~#2\end{tabular}\\\begin{tabular}{*{2}{@{}p{0.5\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{1\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}}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{blindtext}
\begin{document}
\blindtext
\choice{aaaaaa}{bbb}{cccccccccccccccccccccccccc}{dd}
\blindtext
\choice{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}{bbb}{cccccccccccccccccccccccccc}{dd}
\blindtext
\choice{aaaaaaaaa}{bbb}{ccccccccccc}{dd}
\end{document}

方法1

方法2

\documentclass{article}
%------------- 选择题 --------------%
\usepackage{tasks}%选择题宏包,tasks环境
\settasks{counter-format={tsk[A].},
	label-offset={0.4em},
	label-align=left,
	column-sep={2pt},
	item-indent={1pt},before-skip={-0.7em},after-skip={-0.7em}}
% 选择题示例 
%\begin{tasks}(4)
%	\task 
%	\task 
%	\task 
%	\task 
%\end{tasks}
%------------- 选择题 --------------%
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{tasks}(4)
\task $f(x)$
\task $g(x)$
\task $h(x)$
\task $\varphi(x)$
\end{tasks}
\blindtext
\begin{tasks}(2)
\task $f(x)$
\task $g(x)$
\task $h(x)$
\task $\varphi(x)$	
\end{tasks}
\blindtext
\begin{tasks}(1)
\task $f(x)$
\task $g(x)$
\task $h(x)$
\task $\varphi(x)$	
\end{tasks}
\end{document}

方法2

转载于:https://my.oschina.net/shaodongtang/blog/2250063

  • 5
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值