我正在课堂上写数学试卷exam
,我想制作一些方框,让学生在里面写下答案。我试过此解决方案,但该框超出了右页边距 6.79999pts。这里出了什么问题?
梅威瑟:
\documentclass[12pt, a4paper]{exam}
\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}
\usepackage[margin=1in,showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fouriernc}
\usepackage{calc}
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\newlength{\whatsleft}
\newcommand{\measureremainder}[1]{%
\begin{tikzpicture}[overlay,remember picture]
% Measure distance to right text border
\path let \p0 = (0,0), \p1 = (current page text area.east) in
[/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}];
\end{tikzpicture}%
}
\onehalfspacing
\begin{document}
\begin{questions}
\addpoints
\question[8] \emph{Regn ut:}
\begin{parts}
\part[2] $6-(-4) = $ \measureremainder{\whatsleft}\fbox{\begin{minipage}{\whatsleft}\vspace{2em}\hfill\end{minipage}}
\end{parts}
\end{questions}
\end{document}
导致
答案1
您需要考虑盒子填充
\begin{minipage}{\whatsleft-2\fboxsep-2\fboxrule}
但实际上你并不需要 tikz,你只需使用经典的 TeX 领导者即可。
\documentclass[12pt, a4paper]{exam}
\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}
\usepackage[margin=1in,showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fouriernc}
\usepackage{calc}
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\newlength{\whatsleft}
\newcommand{\measureremainder}[1]{%
\begin{tikzpicture}[overlay,remember picture]
% Measure distance to right text border
\path let \p0 = (0,0), \p1 = (current page text area.east) in
[/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}];
\end{tikzpicture}%
}
\onehalfspacing
\begin{document}
\begin{questions}
\addpoints
\question[8] \emph{Regn ut:}
\begin{parts}
\part[2] $6-(-4) = $ \measureremainder{\whatsleft}\fbox{\begin{minipage}{\whatsleft-2\fboxsep-2\fboxrule}\vspace{2em}\hfill\end{minipage}}
\end{parts}
\question[8] \emph{Regn ut:}
\begin{parts}
\part[2] $6-(-4) = $ \vrule\leaders\vbox{\offinterlineskip\hrule width.1pt\vskip\normalbaselineskip\hrule\kern-\dp\strutbox\hrule width0pt depth\dp\strutbox}\hfill\vrule\mbox{}\\dd
\end{parts}
\end{questions}
\end{document}