\documentclass[10pt,UTF]{ctexart}
\usepackage[paperwidth=21cm,paperheight=29.7cm,top=2.6cm,bottom=2.533cm,right=1cm,left=1cm,headheight=24pt,footskip=41pt]{geometry}
\usepackage{ifthen}
\usepackage{amsmath} %数学公式
\usepackage{amssymb} %数学公式
\newlength{\la}
\newlength{\lb}
\newlength{\lc}
\newlength{\ld}
\newlength{\lhalf}
\newlength{\lquarter}
\newlength{\lquartert}
\newlength{\lmax}
\newlength{\surplus}
\newlength{\contentlength}
\newcommand{\choiceF}[4]{%
 \ifnewline \!\\[0pt]%
 \fi%
 \settowidth{\la}{A.#1~~~}%
 \settowidth{\lb}{B.#2~~~}%
 \settowidth{\lc}{C.#3~~~}%
 \settowidth{\ld}{D.#4~~~}%
 \ifthenelse{\lengthtest{\la > \lb}}%
 {\setlength{\lmax}{\la}}{\setlength{\lmax}{\lb}}%
  \ifthenelse{\lengthtest{\lmax < \lc}}  {\setlength{\lmax}{\lc}}  {}  \ifthenelse{\lengthtest{\lmax < \ld}}  {\setlength{\lmax}{\ld}}  {}%
 \ifthenelse{\lengthtest{\lmax > \lhalf}}%
 {\noindent{}A.#1 \\ B.#2 \\ C.#3 \\ D.#4 \\}  {  \ifthenelse{\lengthtest{\lmax > \lquarter}}%
     {\noindent
     \parbox{\lhalf}{A.#1~~~}%
     \parbox{\lhalf}{B.#2~~~}\\\makebox[0.92cm][r]{}%
     \parbox{\lhalf}{C.#3~~~}%
     \parbox{\lhalf}{D.#4~~~}\\}%
     {\noindent\framebox[\lquarter][l]{A.#1~~~}%
     \framebox[\lquarter][l]{B.#2~~~}%
     \framebox[\lquarter][l]{C.#3~~~}%
     \framebox[\lquarter][l]{D.#4~~~}\\}
    }}

\newcommand{\choiceFNoEndLine}[4]{%
 \ifnewline \!\\[0pt]%
 \fi%
 \settowidth{\la}{A.#1~~~}%
 \settowidth{\lb}{B.#2~~~}%
 \settowidth{\lc}{C.#3~~~}%
 \settowidth{\ld}{D.#4~~~}%
 \ifthenelse{\lengthtest{\la > \lb}}%
 {\setlength{\lmax}{\la}}{\setlength{\lmax}{\lb}}%
  \ifthenelse{\lengthtest{\lmax < \lc}}  {\setlength{\lmax}{\lc}}  {}  \ifthenelse{\lengthtest{\lmax < \ld}}  {\setlength{\lmax}{\ld}}  {}%
 \ifthenelse{\lengthtest{\lmax > \lhalf}}%
 {\noindent{}A.#1 \\ B.#2 \\ C.#3 \\ D.#4}  {  \ifthenelse{\lengthtest{\lmax > \lquarter}}%
     {\noindent%
     \parbox{\lhalf}{A.#1~~~}%
     \parbox{\lhalf}{B.#2~~~}\\%
     \parbox{\lhalf}{C.#3~~~}%
     \parbox{\lhalf}{D.#4~~~}}%
     {\noindent\framebox[\lquarter][l]{A.#1~~~}%
     \framebox[\lquarter][l]{B.#2~~~}%
     \framebox[\lquarter][l]{C.#3~~~}%
     \framebox[\lquarter][l]{D.#4~~~}}%
    }}



\newif\ifnewline
\newlinefalse



\newcommand{\setlinewidth}[1]{
\setlength{\linewidth}{#1}
\setlength{\lhalf}{0.5\linewidth}
\setlength{\lquarter}{0.25\linewidth}
\setlength{\lquartert}{0.75\linewidth}
}

\setlength{\parskip}{1mm}
\linespread{1.9}
\begin{document}
\par
\hangindent 0.4cm
\hangafter 1
\noindent
\makebox[0.4cm][r]{1. }我是大题题干
\\
\setlinewidth{17.6cm}
\framebox[1cm][r]{(1).}\choiceF{a}{b}{c}{d}
\framebox[1cm][r]{(2).}\choiceF{1}{2}{3}{4}
\framebox[1cm][r]{(3).}\choiceF{2}{2}{3}{4}
\framebox[1cm][r]{(4).}\choiceF{3}{2}{3}{4}
\framebox[1cm][r]{(5).}\choiceF{5}{2}{3}{4}
\framebox[1cm][r]{(6).}\choiceF{6}{2}{3}{4}
\framebox[1cm][r]{(7).}\choiceF{7}{2}{3}{4}
\framebox[1cm][r]{(8).}\choiceF{8}{2}{3}{4}
\framebox[1cm][r]{(9).}\choiceF{9}{2}{3}{4}
\framebox[1cm][r]{(10).}\choiceFNoEndLine{10}{2}{3}{4}
\par
\hangindent 0.4cm
\hangafter 1
\noindent
\makebox[0.4cm][r]{2. }我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干
\\
\newlinetrue
\setlinewidth{18.6cm}
(1).\choiceF{a}{b}{c}{d}
(2).\choiceF{1}{2}{3}{4}
(3).\choiceF{2}{2}{3}{4}
(4).\choiceF{3}{2}{3}{4}
(5).\choiceF{5}{2}{3}{4}
(6).\choiceF{6}{2}{3}{4}
(7).\choiceF{7}{2}{3}{4}
(8).\choiceF{8}{2}{3}{4}
(9).\choiceF{9}{2}{3}{4}
(10).\choiceFNoEndLine{10}{2}{3}{4}
\par
\hangindent 0.4cm
\hangafter 1
\noindent
\makebox[0.4cm][r]{3. }我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干我是大题题干
\end{document}

image.png

这个多余的空白是怎么来的,怎么去掉?

2 回答2

1
<p><br>你检查一下宏定义里面,所有\ifthenelse前面的空格<br><br>那些空格直接被放进去了<br></p><p><br></p><p>细节藏在魔鬼之中</p>
  • 回复 五谷丰登 :啊, 我只是为了方便看问题才替换的framebox,本来是makebox,看起来是对称的 – wlianghe00 2020-05-09 17:51 回复
  • 回复 wlianghe00 :我个人觉得很丑,建议换一种解决方案 – 五谷丰登 2020-05-09 17:43 回复
  • 回复 wlianghe00 :但是你有没有发现,A,B,C,D 这四个盒子水平高度不一样,为了区分是不同的格子。 – 五谷丰登 2020-05-09 17:43 回复
  • 非常感谢! – wlianghe00 2020-05-09 15:14 回复
  • 是的,我发现了,就这里^_^ – wlianghe00 2020-05-09 15:14 回复
0
<p><img src="/data/ueditor/php/upload/image/20200509/1589017956944207.png" title="1589017956944207.png" alt="image.png"></p><p>最终效果</p>

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。