4

Here my actual document

enter image description here

The following picture is what I would like to have (see picture below), but I don't know how to do it. Could someone help to do this presentation ? I would like to have a margin at left of 2cm for grading (here I have 4 cm), and at the right hand side, I would like to have a margin of 4.5 cm with written : Do not write in this column (to put comment during the correction). enter image description here

Here is my code :

\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}

\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]$.\\


\begin{tikz}[color=gray!60]
\draw (0,0) grid[step=0.4] (15.2,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] (15.2,2.4);
\end{tikz}
\end{enumerate}
\end{document}
3
  • 1
    Please make your example code compilable.
    – leandriis
    Dec 28, 2019 at 13:16
  • @leandriis: Is this better ?
    – Surb
    Dec 28, 2019 at 13:22
  • 1
    Why do you want the "Do not write here" with the cross in the first place? Imho, it looks terrible while not providing anything.
    – Skillmon
    Dec 28, 2019 at 14:41

2 Answers 2

6

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.

enter image description here

\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}

enter image description here

\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}
3
  • Thank you, indeed it's much better, but unfortunately, the grid is to much at right (I think that with your code, it's the text that start at 2cm from the left border). Also, I would like to have the cross with two lines in blue, and also the "Do not write in this column" beside the grid and not beside the first question. Do you think it's possible ?
    – Surb
    Dec 28, 2019 at 13:51
  • 1
    @Surb: I have updated my answer accordingly. You can of course adjust the size of the blue diagonal lines according to your needs.
    – leandriis
    Dec 28, 2019 at 14:47
  • 1
    The tikzpagenodes package would help (current page marginpar area). Dec 28, 2019 at 16:40
6

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}

enter image description here

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .