This MWE is part of an exam. Before each question I put a box in the left margin that includes the question number and the max score.
For this MWE only, I changed the \makebox into a \framebox to emphasize my problem below.
The question itself (the content) is supposed to start right AT the end of the left margin, so right UNDER the start of the preceding paragraph. My two problems:
The box seems to occupy more space than I expect: 1.7cm
The box seems to have some space around it, which I don't want.
Obviously I tried to compensate it with negative \hspace, but in more complex real exams, this compensation takes different values, so you keep on adjusting.
How to have a box sized exactly 1.7cm and not more and how to have no space/glue or whatever between the box and the succeeding text?
\documentclass[12pt,a4paper,notitlepage]{report}
\usepackage[left=25mm,right=25mm,top=15mm,height=252mm,includefoot]{geometry}
\usepackage{showframe} % temporary, to emphasize my point !
\usepackage{xifthen} % conditionals, booleans
\setlength{\parindent}{0mm} % no paragraph indentation
\newcounter{countSubExercises} % number of sub level exercises: a,b,c,...
\newlength{\boxWidth}
\setlength{\boxWidth}{1.7cm}
\newcommand{\newSubEx}[2]
% #1 = no. of score pts
% #2 = content
{
\refstepcounter{countSubExercises} % increment subEx counter
% box with question nr and max score in the left margin
\hspace*{-\boxWidth}
\framebox[\boxWidth][r]{{\tiny\sl #1p}\enspace{\bf\alph{countSubExercises}}\enspace}
#2\\
}
\begin{document}
\chapter*{Exercise title}
A first instructive paragraph\\
\newSubEx{2}{Comment on blah blah ...}
\\
\\
A second instructive paragraph\\
\newSubEx{4}{Calculate the perimeter of ...}
\end{document}


%-loss-syndrome. While space inside your code is good for readability, you need to be cautious, as TeX gobbles some spaces but not all. See What is the use of percent signs (%) at the end of lines? – Werner Feb 04 '15 at 19:15\textitor\it,\bfseriesor\bf, etc. and Will two-letter font style commands (\bf,\it, …) ever be resurrected in LaTeX? – Werner Feb 04 '15 at 19:15\\to denote a paragraph break, since it technically doesn't represent a paragraph break. Instead use a blank line in your code, or insert an explicit\par. – Werner Feb 04 '15 at 19:16\frameboxintroduces its own extra space, as governed by\fboxsep(and of course the rule itself is of thickness\fboxrule). These do not apply for a\makebox. – Steven B. Segletes Feb 05 '15 at 02:19