4

How can I remove space betwwen two vbox minimal code

\documentclass{article}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\setlength\parindent{0pt}
\begin{document}
    \setbox0=\vbox{\hsize=.5\linewidth Hi}
    \setbox1=\vbox{\hsize=.5\linewidth everyone}
    \setbox2=\hbox{\vrule\box0\vrule\box1\vrule}
    \setbox3=\vbox{\hrule\box2\hrule}
    \copy3\copy3
\end{document}

output enter image description here Thanks

4

You have to remove the interline glue.

\documentclass{article}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\setlength\parindent{0pt}
\begin{document}

\setbox0=\vbox{\hsize=.5\linewidth Hi}
\setbox2=\vbox{\hsize=.5\linewidth everyone}
\setbox4=\hbox{\vrule\box0\vrule\box2\vrule}
\setbox6=\vbox{\hrule\box4\hrule}
\copy6\nointerlineskip\kern-0.4pt\copy6

\end{document}

I also added a kern to superimpose the two rules and changed the register numbers; as a general rule, for this purpose only even numbered registers should be used.

enter image description here

2

The space between the \vboxes is controlled by the \baselineskip and \lineskip glues. If you make them box zero, the boxes will be glued together.

I enclosed the setting of the skips in a group to prevent it from affecting the rest of the document.

\documentclass{article}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\setlength\parindent{0pt}
\begin{document}
    \setbox0=\vbox{\hsize=.5\linewidth Hi}
    \setbox1=\vbox{\hsize=.5\linewidth everyone}
    \setbox2=\hbox{\vrule\box0\vrule\box1\vrule}
    \setbox3=\vbox{\hrule\box2\hrule}
    {\baselineskip=0pt
    \lineskip=0pt
    \copy3\copy3}
\end{document}
1

Once well clarified by others how to deal with interline skips, maybe for newbies is worth to note that the same result can be obtained much easier with a simple table, without having to worry about line skips (... well, really a better result, as the central horizontal line is only typed once).

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{|>{Hi}X|>{everyone}X|}
\hline&\\\hline&\\\hline\end{tabularx}
\end{document}

mwe

  • I know about tabular environment. this minimal code was just for reveal my problem not real used code. Thanks for your attention and excuse me for my bad English. – mojtaba baghban Apr 29 '18 at 17:39

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.