2

I type several fbox commands and for some reason the boxes are separated with small spaces:

enter image description here

MWE:

\documentclass{article}
\usepackage{fullpage}
\setlength{\oddsidemargin}{-15mm}

\raggedright

\begin{document}

\noindent
\fbox{text text text text text text text text text text text}
\fbox{text text text text text text text text text text text}
\fbox{text text text text text text text text text text text}
\fbox{text text text text text text text text text text text}

\end{document}

My first thought was that this is due to justification. But then I left aligned the contents and the "problem" is still there.

I want to remove space between these fboxes: both vertical and horizontal (shown on the screenshot with red arrows).

Edit:

The original problem is to generate badges with datatool. I have a badge template and I generate it many times from a csv file using datatool. The problem is that badges are a little bit apart from each other so I would have to cut them out manually later.

MWE:

\documentclass[a4paper,12pt]{article}
\usepackage{fullpage}
\usepackage{filecontents}
\usepackage{datatool}

\DTLsetseparator{&}

\pagestyle{empty}

\setlength{\oddsidemargin}{-15mm}


\begin{filecontents*}{data.csv}
NAME&TITLE
Name1 & Title1
Name2 & Title2
Name3 & Title3
Name4 & Title4
Name5 & Title5
Name6 & Title6
\end{filecontents*}

\DTLloaddb{data}{data.csv}

\begin{document}

\DTLforeach*
{data}
{\NAME=NAME,\TITLE=TITLE}
{
  \noindent
  \fbox{\begin{minipage}[t][55mm]{90mm}
      \vspace{11mm}

      \centering
      \vfill
      {\bf \fontsize{30}{36}\selectfont\textrm{\NAME}\par}
      \vfill

      \large\itshape\TITLE

      \vspace{5mm}

    \end{minipage}}
}

\end{document}

Gives:

enter image description here

Edit:

In case one is going to use two-sided badges -- one would want to have same name written twice, as is allows to bend the badge and have the same name on both sides. In this case one might use:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{data.csv}
NAME&AFFILIATION
Name1 & Title1
Name2 & Title2
Name3 & Title3
Name4 & Title4
Name5 & Title5
\end{filecontents*}

\usepackage{datatool}
\DTLsetseparator{&}
\DTLloaddb{data}{data.csv}

\usepackage{eso-pic}
\usepackage{graphicx}

% 4 per in a column:
\usepackage[a4paper,top=1cm,bottom=1cm,left=0.5in,right=0.5in]{geometry}

% % 5 per in a column:
% \usepackage[a4paper,top=0.27cm,bottom=0.1cm,left=0.5in,right=0.5in]{geometry}


\pagestyle{empty}

\begin{document}

\par
% \offinterlineskip
\noindent % <- Outside the loop
\DTLforeach*{data}{\NAME=NAME,\AFFILIATION=AFFILIATION}
{% <- Spurious space was here
  \allowbreak % <- Added
  \fbox{\begin{minipage}[t][55mm]{90mm}
      \vspace{11mm}

      \centering
      \vfill
      {\bf \fontsize{30}{36}\selectfont\textrm{\NAME}\par}
      \vfill

      \large\itshape\AFFILIATION

      \vspace{5mm}

    \end{minipage}}% <- Spurious space was here
  \fbox{\begin{minipage}[t][55mm]{90mm}
      \vspace{11mm}

      \centering
      \vfill
      {\bf \fontsize{30}{36}\selectfont\textrm{\NAME}\par}
      \vfill

      \large\itshape\AFFILIATION

      \vspace{5mm}

    \end{minipage}}% <- Spurious space was here
}

\end{document}

Which gives:

enter image description here

4
  • what about using a table?
    – Guido
    Aug 26 '15 at 16:35
  • @Guido: the original problem is to generate badges with datatool. I have a badge template and I generate it many times from a csv file using datatool. The problem is that badges are a little bit apart from each other so I would have to cut them out manually later.
    – Adobe
    Aug 26 '15 at 16:36
  • There are spurious blank spaces in your code producing the undesired horizontal separation. You should have mentioned the original problem since the beginning! Aug 26 '15 at 16:51
  • @GonzaloMedina: I thought it was too detailed. Sorry about that.
    – Adobe
    Aug 26 '15 at 17:06
3

You have spurious spaces. I also removed \noindent from the loop, put it outside, and put \allowbreak before any \fbox. With \offinterlineskip all goes well. If you want to have another things in the document, you should enclose everything in a group \begingroup .. \endgroup.

\documentclass{scrartcl}
\usepackage{lmodern}

\usepackage{fullpage}
\usepackage{filecontents}
\usepackage{datatool}

\DTLsetseparator{&}

\pagestyle{empty}

\setlength\oddsidemargin{-15mm}


\begin{filecontents*}{data.csv}
NAME&TITLE
Name1 & Title1
Name2 & Title2
Name3 & Title3
Name4 & Title4
Name5 & Title5
Name6 & Title6
\end{filecontents*}

\DTLloaddb{data}{data.csv}

\begin{document}

\par
\offinterlineskip
\noindent % <- Outside the loop
\DTLforeach*{data}{\NAME=NAME,\TITLE=TITLE}
{% <- Spurious space was here
  \allowbreak % <- Added
  \fbox{\begin{minipage}[t][55mm]{90mm}
      \vspace{11mm}

      \centering
      \vfill
      {\rmfamily\bfseries\fontsize{30}{36}\selectfont\NAME\par}
      \vfill

      \large\itshape\TITLE

      \vspace{5mm}

    \end{minipage}}% <- Spurious space was here
}

\end{document}
4
  • Ah, I didn't see your answer was I was doing my last edit after seeing what the OP really wanted. I think now my answer is utterly superfluous and will delete it. Aug 26 '15 at 16:59
  • @GonzaloMedina: I think you shouldn't delete answer with 4 upvotes. It shows that it is interesting to users.
    – Adobe
    Aug 26 '15 at 17:01
  • @GonzaloMedina Beat you by a few seconds, I see :) I think the idea of taking \noindent outside and putting \allowbreak inside is good. You can add it to your answer if you want. I will remove mine, since yours is already upvoted. Well, it seems mine is accepted, I won't remove it. But you shouldn't delete it, IMO.
    – Manuel
    Aug 26 '15 at 17:04
  • @Manuel No, it's OK. You answered fine and first, well deserved green tick :) Aug 26 '15 at 17:08
1

Easy for the collumns space. Use % at the end of line to remove any extra space. To remove the vertical space, you have to use negative space to move the box up. (I'll edit soon)

\fbox{text text text text text text text text text text text}%
\fbox{text text text text text text text text text text text}\\
4
  • This makes four of them too long for a page. Is it possible to enable line folding (text wrap) with this solution?
    – Adobe
    Aug 26 '15 at 16:29
  • You solution sill leaves vertical space between fboxes.
    – Adobe
    Aug 26 '15 at 16:30
  • @Adobe, edited.
    – Sigur
    Aug 26 '15 at 16:30
  • \fbox{text text text text text text text text text text text}% \fbox{text text text text text text text text text text text}\\[-0.1\normalbaselineskip] seems to be working.
    – Adobe
    Aug 26 '15 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.