```tex \documentclass[8pt]{extarticle} \usepackage[UTF8]{ctex} \usepackage[paperwidth=21cm,paperheight=29.7cm,top=2.4cm,bottom=2.4cm,right=0.78cm,left=1.78cm]{geometry} \usepackage{fancyhdr} \usepackage{tikz} \setlength{\linewidth}{18.44cm} \makeatletter \newlength{\blk@height} \newlength{\blk@width} \newlength{\blk@cell@ht} \newlength{\blk@cell@dp} \newlength{\blk@cell@total} \newlength{\blk@cell@wd} \setlength{\blk@height}{\dimexpr\pagegoal-\pagetotal\relax} \setlength{\blk@width}{\linewidth} \setlength{\blk@cell@ht}{26pt} \setlength{\blk@cell@dp}{4pt} \setlength{\blk@cell@total}{\dimexpr\blk@cell@ht + \blk@cell@dp\relax} \setlength{\blk@cell@wd}{26pt} %\pgfmathsetmacro{\rowCount}{floor(\blk@height / \blk@cell@total) - 1} \newcommand{\drawBlocks}[1]{% \def\rowCount{#1}% \pgfmathsetmacro{\colCount}{floor(\blk@width / \blk@cell@wd)}% \vspace{\dimexpr\blk@cell@dp-\lineskip\relax} \foreach \y in {0, ..., \rowCount} { \begin{tikzpicture} \draw (0, \y * -\blk@cell@total) -- +(\blk@cell@wd * \colCount, 0) ++(0, -\blk@cell@ht) -- +(\blk@cell@wd * \colCount, 0); \foreach \x in {0, ..., \colCount} { \draw (\x * \blk@cell@wd, \y * -\blk@cell@total) -- +(0pt, -\blk@cell@ht); } \end{tikzpicture} \vspace{\dimexpr\blk@cell@dp-\lineskip\relax} }% } \makeatother \pagestyle{fancy} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} \begin{document} \noindent 12.写作表达\quad\\[0pt]从下面两题中任选一题,按要求完成任务。\quad\\[0pt]\indent \textbf{题一:开在心中的花朵}\quad\\[0pt]\indent \textbf{题二:我最想感谢的人}\quad\\[0pt]\indent 要求:\textcircled{1}不少于600字;\textcircled{2}书写工整,语句通顺,勿写错别字;\textcircled{3}有事例,有真情实感。\quad\\[0pt] \quad\\[0pt] \drawBlocks{40} %\colCount \end{document} ``` ![](https://pics.latexstudio.net/data/images/201912/f5b45fc24cf1cef.png)

2 回答2

1
\documentclass{extarticle} 文档类换成article就正常了,是文档类的问题吧 \documentclass{article}
0
把你的代码修改了。 ```tex \documentclass[8pt]{extarticle} \usepackage[UTF8]{ctex} \usepackage[paperwidth=21cm,paperheight=29.7cm,top=2.4cm,bottom=2.4cm,right=0.78cm,left=1.78cm]{geometry} \usepackage{fancyhdr} \usepackage{tikz} \setlength{\linewidth}{18.44cm} \makeatletter \newlength{\blk@height} \newlength{\blk@width} \newlength{\blk@cell@ht} \newlength{\blk@cell@wd} \setlength{\blk@height}{\dimexpr\pagegoal-\pagetotal\relax} \setlength{\blk@width}{\linewidth} \setlength{\blk@cell@ht}{26pt} \setlength{\blk@cell@wd}{26pt} \newcommand{\drawBlocks}[1]{% \def\rowCount{#1}% \pgfmathsetmacro{\colCount}{floor(\blk@width / \blk@cell@wd)}% \foreach \n in {1, ..., \rowCount} {% \ifnum\n=\rowCount% \def\aaaa{\relax}% \else% \def\aaaa{\\[4pt]}% \fi% \begin{tikzpicture}[line width=0.8pt] \draw (0, 0) -- ++(\blk@cell@wd * \colCount, 0) --++(0, \blk@cell@ht) -- ++(-\blk@cell@wd * \colCount, 0) -- cycle; \foreach \x in {0, ..., \colCount} { \draw (\x * \blk@cell@wd, 0) -- +(0pt, \blk@cell@ht); } \end{tikzpicture}\aaaa }% } \makeatother \pagestyle{fancy} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} \begin{document} \noindent 12.写作表达\quad\\[0pt]从下面两题中任选一题,按要求完成任务。\quad\\[0pt]\indent \textbf{题一:开在心中的花朵}\quad\\[0pt]\indent \textbf{题二:我最想感谢的人}\quad\\[0pt]\indent 要求:\textcircled{1}不少于600字;\textcircled{2}书写工整,语句通顺,勿写错别字;\textcircled{3}有事例,有真情实感。 \vspace{3mm} \noindent \drawBlocks{40} \end{document} ``` 我编译后没问题。
  • 应该是vspace的问题,我换成\\[4pt]就可以了 – wlianghe00 2019-12-18 17:22 回复
  • 第一行和第二行之间的间距不对 – wlianghe00 2019-12-18 16:47 回复

你的回答

请登录后回答

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