3

I would like to create homework sheet solution to looks like the following image

enter image description here

My code

\documentclass{article}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{graphicx}
\begin{document}

\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.8pt}}
\begin{center}
    {\Large \textbf{Big title N 1 }}\\
(small title)   
\end{center}
\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.8pt}}
\begin{center}
{\large \fbox{Exercise} }
\end{center}
\noindent\rule{10cm}{0.8pt}\fbox{1}  \noindent\rule{10cm}{0.8pt}
show that $$\int_{}^{} $$
\noindent\rule{10cm}{0.8pt}\fbox{2}  \noindent\rule{10cm}{0.8pt}
\begin{itemize}
\item 
\item 
\end{itemize}
\noindent\rule{10cm}{0.8pt}\fbox{text}  \noindent\rule{10cm}{0.8pt}
\begin{itemize}
\item 
\item 
\end{itemize}

\noindent\rule{10cm}{0.8pt}\fbox{large text}  \noindent\rule{10cm}{0.8pt}

% document content here
\end{document}
  • How to do that?
4
  • 2
    Please, what exactly is your question? How to do that? Or do you have a special problem you can't solve? Please describe your problem better, thanks!
    – Mensch
    Commented May 16, 2016 at 20:45
  • How to do that?
    – Educ
    Commented May 16, 2016 at 20:49
  • Do you really want these lines to go outside the margins (\paperwidth)? Commented May 16, 2016 at 21:17
  • no i want them to be like the image above
    – Educ
    Commented May 16, 2016 at 21:20

1 Answer 1

3

Using \fbox

\documentclass{article}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{graphicx}

\newcommand{\centerbox}[1]% #1 = text
{\bgroup% use local definitions
  \parskip=0pt
  \sbox0{\fbox{#1}}
  \dimen0=\dimexpr 0.5\textwidth - 0.5\wd0\relax
  \par\noindent\rule{\dimen0}{0.8pt}\box0\rule{\dimen0}{0.8pt}\par
\egroup}

\begin{document}

\noindent{\rule{\textwidth}{0.8pt}}
\begin{center}
    {\Large \textbf{Big title N 1 }}\\
(small title)   
\end{center}
\noindent\rule{\textwidth}{0.8pt}
\begin{center}
{\large \fbox{Exercise}}
\end{center}
\centerbox{1}%
show that $$\int_{}^{} $$
\centerbox{2}
\begin{itemize}
\item
\item
\end{itemize}
\centerbox{text}
\begin{itemize}
\item 
\item 
\end{itemize}

\centerbox{large text}

% document content here
\end{document}

Using TikZ (rounded corners)

\documentclass{article}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{tikz}

\newcommand{\centerbox}[1]% #1 = text
{\bgroup% use local definitions
  \parskip=0pt
  \parindent=0pt
  \sbox0{\tikz[baseline]{\node[draw,rounded corners,anchor=base]{#1};}}%
  \dimen0=\dimexpr 0.5\textwidth - 0.5\wd0\relax
  \par\rule{\dimen0}{0.8pt}\box0\rule{\dimen0}{0.8pt}\par
\egroup}

\begin{document}

\noindent{\rule{\textwidth}{0.8pt}}
\begin{center}
    {\Large \textbf{Big title N 1 }}\\
(small title)   
\end{center}
\noindent\rule{\textwidth}{0.8pt}
\begin{center}
\tikz[baseline]{\node[draw,rounded corners=0.8ex,anchor=base]{\large Exercise}}
\end{center}
\centerbox{1}%
show that $$\int_{}^{} $$
\centerbox{2}
\begin{itemize}
\item
\item
\end{itemize}
\centerbox{text}
\begin{itemize}
\item 
\item 
\end{itemize}

\centerbox{large text}

% document content here
\end{document}

Using tcolorbox (\tcbox)

\documentclass{article}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{tcolorbox}

\newcommand{\centerbox}[1]% #1 = text
{\bgroup% use local definitions
  \parskip=0pt
  \parindent=0pt
  \sbox0{\tcbox[tcbox raise base]{#1}}%
  \dimen0=\dimexpr 0.5\linewidth - 0.5\wd0\relax
  \par\rule{\dimen0}{0.8pt}\box0\rule{\dimen0}{0.8pt}\par
\egroup}

\begin{document}

\noindent\rule{\textwidth}{0.8pt}
\begin{center}
    {\Large \textbf{Big title N 1 }}\\
(small title)   
\end{center}
\noindent\rule{\textwidth}{0.8pt}
\begin{center}
\tcbox[tcbox raise base]{\large Exercise}
\end{center}
\centerbox{1}%
show that $$\int_{}^{} $$
\centerbox{2}
\begin{itemize}
\item
\item
\end{itemize}
\centerbox{text}
\begin{itemize}
\item 
\item 
\end{itemize}

\centerbox{large text}

% document content here
\end{document}
5
  • thanks for ur help but the box in image is not as mine, ours are square
    – Educ
    Commented May 16, 2016 at 21:54
  • Then you want to use the tikz or tcolorbox packages. Commented May 16, 2016 at 21:57
  • I would appreciate it if you could you make both ways thanks in advance and for ur time
    – Educ
    Commented May 16, 2016 at 21:59
  • please could you do it also with tcolorbox
    – Educ
    Commented May 17, 2016 at 14:34
  • It should be noted that anything tcolorbox does is actually done with tikz. Commented May 17, 2016 at 20:45

You must log in to answer this question.

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