# Broken box is showing in the compiled pdf

Broken box is showing in the compiled pdf. See my LaTeX code below:

\documentclass{article}
\usepackage{graphicx}
\usepackage{a4wide}

\usepackage{tabularx}

\makeatletter
\newenvironment{problem}[2][]{%
\def\problem@arg{#1}%
\def\problem@framed{framed}%
\def\problem@lined{lined}%
\def\problem@doublelined{doublelined}%
\ifx\problem@arg\@empty%
\def\problem@hline{}%
\else%
\ifx\problem@arg\problem@doublelined%
\def\problem@hline{\hline\hline}%
\else%
\def\problem@hline{\hline}%
\fi%
\fi%
\ifx\problem@arg\problem@framed%
\def\problem@table{\tabularx{\textwidth}{|>{\bfseries}lX|c}}%
\def\problem@title{\multicolumn{2}{|l|}{%
\raisebox{-\fboxsep}{\textsc{\Large #2}}%
}}%
\else
\def\problem@table{\tabularx{\textwidth}{>{\bfseries}lXc}}%
\def\problem@title{\multicolumn{2}{l}{%
\raisebox{-\fboxsep}{\textsc{\Large #2}}%
}}%
\fi%
\bigskip\par\noindent%
\renewcommand{\arraystretch}{1.2}%
\problem@table%
\problem@hline%
\problem@title\\[2\fboxsep]%
}{%
\\\problem@hline%
\endtabularx%
\medskip\par%
}
\makeatother

\section{Introduction}

Given  two graphs $G =(V,E_1)$ and $H = (V,E_2)$  are said to be isomorphic if there exists a bijection $\phi: V \mapsto V$ that preserves the edges and non-edges. Similarliy two groups $(G,\circ)$ and $(H,\times )$ are said to be isomorphic if there exist an bijective map from $\pi : G \mapsto H$ such that $\forall a,b \in G, \pi(a\circ b) = \pi(a) \times \pi(b)$.
Graph isomorphism is strongly related to group theoretic problems like group isomorphism, group intersection etc. Grpah Isomorphism is known to be in $\mathsf{NP}$, not known to be in $\mathsf{P}$ and very unlikely to be $\mathsf{NP}$-complete.

\begin{problem}[framed]{Graph Isomorphism (GI)}
Inpu: & Two graphs $G=(V,E_1)$ and $H=(V,E_2)$. \\
Problem: & Is $G$ isomorphic to $H$? \\

\end{problem}
\end{document}


• Try leaving out the \\  of the last line. – CarLaTeX Feb 5 '18 at 6:46
• Off-topic but still of interest: (i) Use \colon instead of : (two instances) in the paragraph that precedes the problem environment. Why? In math mode, : is taken to be a relational operator, which doesn't apply here. (ii) The readability of all-uppercase and all-smallcaps text strings improves significantly if these strings are letterspaced. To achieve this goal, I suggest you load the microtype package and encase both instances of \textsc{\Large #2} in \textls{...} directives. (iii) Writing $\mathsf{NP}$ seems unnecessarily complicated; try writing \textsf{NP} instead. – Mico Feb 5 '18 at 8:06

Please do not use package a4wide any longer! See Ctan!

To get rid of the broken box you have to delete/comment the \\ I marked with <===== in the following MWE:

\documentclass{article}

%\usepackage{a4wide} % <=========================== use package geometry
\usepackage[a4paper]{geometry}
\usepackage{graphicx}
\usepackage{tabularx}

\makeatletter
\newenvironment{problem}[2][]{%
\def\problem@arg{#1}%
\def\problem@framed{framed}%
\def\problem@lined{lined}%
\def\problem@doublelined{doublelined}%
\ifx\problem@arg\@empty%
\def\problem@hline{}%
\else%
\ifx\problem@arg\problem@doublelined%
\def\problem@hline{\hline\hline}%
\else%
\def\problem@hline{\hline}%
\fi%
\fi%
\ifx\problem@arg\problem@framed%
\def\problem@table{\tabularx{\textwidth}{|>{\bfseries}lX|c}}%
\def\problem@title{\multicolumn{2}{|l|}{%
\raisebox{-\fboxsep}{\textsc{\Large #2}}%
}}%
\else
\def\problem@table{\tabularx{\textwidth}{>{\bfseries}lXc}}%
\def\problem@title{\multicolumn{2}{l}{%
\raisebox{-\fboxsep}{\textsc{\Large #2}}%
}}%
\fi%
\bigskip\par\noindent%
\renewcommand{\arraystretch}{1.2}%
\problem@table%
\problem@hline%
\problem@title\\[2\fboxsep]%
}{%
%     \\% <=============================================================
\problem@hline%
\endtabularx%
\medskip\par%
}
\makeatother

\begin{document}

\section{Introduction}

Given  two graphs $G =(V,E_1)$ and $H = (V,E_2)$  are said to be
isomorphic if there exists a bijection $\phi: V \mapsto V$ that
preserves the edges and non-edges. Similarliy two groups $(G,\circ)$ and
$(H,\times )$ are said to be isomorphic if there exist an bijective map
from $\pi : G \mapsto H$ such that
$\forall a,b \in G, \pi(a\circ b) = \pi(a) \times \pi(b)$.
Graph isomorphism is strongly related to group theoretic problems like
group isomorphism, group intersection etc. Grpah Isomorphism is known
to be in $\mathsf{NP}$, not known to be in $\mathsf{P}$ and very
unlikely to be $\mathsf{NP}$-complete.

\begin{problem}[framed]{Graph Isomorphism (GI)}
Input: & Two graphs $G=(V,E_1)$ and $H=(V,E_2)$. \\
Problem: & Is $G$ isomorphic to $H$? \\

\end{problem}
\end{document}


You get the result: