Presentation of an exam using Tikz
With the help of the geoemtry
package you can adjust the margin sized. In the following MWE, I have also added marginpar
to write the text in the right margins. Lastly, I have also modified the width of the grid to automatically fit into the textblock.
\documentclass [a4paper,10pt]{report}
%%%% PACKAGE %%%%%%%%%%%%%%%%%%%
%\usepackage{fullpage}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{marginnote}
\usepackage{calc}
\usepackage[left=2cm, right=4.5cm, marginparwidth=3.5cm]{geometry}
\begin{document}
\subsection*{Exercise 1}
\marginpar{Do not write in this column}
\begin{enumerate}
\item Let $f:\mathbb R\to \mathbb R$ the function defined by $f(x)=\frac{\sin(x)}{x}$. Prove it's continuous on $(0,1]$.\\
\begin{tikz}[color=gray!60]
\draw (0,0) grid[step=0.4] (\textwidth-\leftmargin,2.4);
\end{tikz}
\ \\
\item Let $g:\mathbb R\to \mathbb R$ the function defined by $g(x)=\frac{\sin(x)}{x^2}$. Prove it's continuous on $(0,1]$.\\
\begin{tikz}[color=gray!60]
\draw (0,0) grid[step=0.4] (\textwidth-\leftmargin,2.4);
\end{tikz}
\end{enumerate}
\end{document}
\documentclass [a4paper,10pt]{report}
%%%% PACKAGE %%%%%%%%%%%%%%%%%%%
%\usepackage{fullpage}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{marginnote}
\usepackage{calc}
\usepackage[left=2cm-\leftmargin, right=4.5cm, marginparwidth=3.5cm]{geometry}
\begin{document}
\subsection*{Exercise 1}
\begin{enumerate}
\item Let $f:\mathbb R\to \mathbb R$ the function defined by $f(x)=\frac{\sin(x)}{x}$. Prove it's continuous on $(0,1]$.\\
\marginpar{\color{blue} \centering Do not write in this column \begin{tikzpicture}\draw (0,0) -- (\marginparwidth,2); \draw (\marginparwidth,0) -- (0,2); \end{tikzpicture}}
\begin{tikz}[color=gray!60]
\draw (0,0) grid[step=0.4] (\textwidth-\leftmargin,2.4);
\end{tikz}
\ \\
\item Let $g:\mathbb R\to \mathbb R$ the function defined by $g(x)=\frac{\sin(x)}{x^2}$. Prove it's continuous on $(0,1]$.\\
\begin{tikz}[color=gray!60]
\draw (0,0) grid[step=0.4] (\textwidth-\leftmargin,2.4);
\end{tikz}
\end{enumerate}
\end{document}
The following provides code that will fill the horizontally available space with a grid. Horizontally only multiples of the grid-step will be filled. You can specify the line width
, the grid step
, the height
and color
:
\documentclass [a4paper,10pt]{report}
%%%% PACKAGE %%%%%%%%%%%%%%%%%%%
\usepackage{fullpage}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{hyperref}
\usepackage{enumitem}
\pgfkeys
{%
/surb/.cd,
,step/.initial=0.4cm
,height/.initial=2.4cm
,line width/.initial=0.4pt
,color/.initial=gray!60
}
\newcommand\surbval[1]{\pgfkeysvalueof{/surb/#1}}
\newcommand\gridfill[1][]
{%
\begingroup
\leavevmode
\pgfkeys{/surb/.cd,#1}%
\null
\leaders\hbox
{%
\tikz\draw[color=\surbval{color}, line width=\surbval{line width}]
(0,0) grid [step=\surbval{step}]
(\surbval{step},\surbval{height})%
(0,0) rectangle (\surbval{step},\surbval{height})
;%
\kern-\surbval{line width}\relax
}%
\hfill
\kern\surbval{line width}\relax
\endgroup
}
\usepackage{showframe} % just to show that it'll not create overfull lines
\begin{document}
\subsection*{Exercise 1}
\begin{enumerate}
\item Let $f:\mathbb R\to \mathbb R$ the function defined by
$f(x)=\frac{\sin(x)}{x}$. Prove it's continuous on $(0,1]$.\\
\gridfill
\item Let $g:\mathbb R\to \mathbb R$ the function defined by
$g(x)=\frac{\sin(x)}{x^2}$. Prove it's continuous on $(0,1]$.\\
\gridfill[height=4cm]
\end{enumerate}
\end{document}
EDIT: Because someone mentioned this to me in an otherwise unrelated chat.
The following adds another key to \gridfill
, namely height target
, which will set the overall used height just like the height
key, but the actual grid will only be drawn in multiples of step
, so that the remaining space will be blank (padding to the top). It will be used if height target
is bigger than 0pt
, and has to be a valid TeX length (so needs a valid unit).
\documentclass [a4paper,10pt]{report}
%%%% PACKAGE %%%%%%%%%%%%%%%%%%%
\usepackage{fullpage}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{hyperref}
\usepackage{enumitem}
\pgfkeys
{%
/surb/.cd,
,step/.initial=0.4cm
,height/.initial=2.4cm
,height target/.initial=-\maxdimen
,line width/.initial=0.4pt
,color/.initial=gray!60
}
\newcommand\surbval[1]{\pgfkeysvalueof{/surb/#1}}
\newcommand*\surbtmp{}
\newcommand\gridfill[1][]
{%
\begingroup
\leavevmode
\pgfkeys{/surb/.cd,#1}%
\null
\leaders\hbox
{%
\ifdim\surbval{height target}>0pt
\pgfmathsetmacro\surbtmp
{int(\surbval{height target}/\surbval{step})*\surbval{step}}%
\pgfkeyssetvalue{/surb/height}{\surbtmp pt}%
\rule{0pt}{\surbval{height target}}%
\fi
\tikz\draw[color=\surbval{color}, line width=\surbval{line width}]
(0,0) grid [step=\surbval{step}]
(\surbval{step},\surbval{height})%
(0,0) rectangle (\surbval{step},\surbval{height})
;%
\kern-\surbval{line width}\relax
}%
\hfill
\kern\surbval{line width}\relax
\endgroup
}
\usepackage{showframe} % just to show that it'll not create overfull lines
\begin{document}
\subsection*{Exercise 1}
\begin{enumerate}
\item Let $f:\mathbb R\to \mathbb R$ the function defined by
$f(x)=\frac{\sin(x)}{x}$. Prove it's continuous on $(0,1]$.\\
\gridfill[height target=4.3cm]
\item Let $g:\mathbb R\to \mathbb R$ the function defined by
$g(x)=\frac{\sin(x)}{x^2}$. Prove it's continuous on $(0,1]$.\\
\gridfill[height=4cm]
\end{enumerate}
\end{document}