如何删除列之间的边距

如何删除列之间的边距

我创建了一个由三列组成的文档。

我的源代码:

\documentclass[a4paper,12pt]{minimal}

\usepackage[margin={2cm, 1.5cm}]{geometry}
\usepackage{polski}
\usepackage{calc}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}

\tcbset
{
  colback=gray!70,
  arc=0pt,arc=0pt,    
  colframe=blue,
  enhanced,
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
% PARAMETERS                                                                    %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newlength{\marginbetweencolumns}
\newlength{\leftcolumnwidth}
\newlength{\middlecolumnwidth}
\newlength{\rightcolumnwidth}

\setlength{\parindent}{0cm}

\setlength{\marginbetweencolumns}{0mm}
\setlength{\leftcolumnwidth}{5cm}
\setlength{\middlecolumnwidth}{5cm}
\setlength{\rightcolumnwidth}{\textwidth-\leftcolumnwidth-\marginbetweencolumns-\middlecolumnwidth-\marginbetweencolumns}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
% ENVIRONMENTS                                                                  %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newenvironment{docleftcolumn}
{  
  \begin{minipage}[t]{\leftcolumnwidth}
  \vspace{0pt}
  \begin{tcolorbox}
}
{
  \end{tcolorbox}
  \end{minipage}
}

\newenvironment{docmiddlecolumn}
{
  \begin{minipage}[t]{\middlecolumnwidth}
  \vspace{0pt}
  \begin{tcolorbox}
}
{
  \end{tcolorbox}
  \end{minipage}
}

\newenvironment{docrightcolumn}
{
  \begin{minipage}[t]{\rightcolumnwidth}
  \vspace{0pt}
  \begin{tcolorbox}
}
{
  \end{tcolorbox}  
  \end{minipage}
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
% DOCUMENT BODY                                                                 %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{docleftcolumn}
Column 1
\end{docleftcolumn}
\begin{docmiddlecolumn}
Column 2
\end{docmiddlecolumn}
\begin{docrightcolumn}
Column 3
\end{docrightcolumn}

\end{document}

我生成了一个如下所示的pdf文档:

PDF 文档

我想删除列之间的边距。有人能帮我吗?

答案1

为了避免出现空格,请在\newenvironment定义的每一行末尾添加一个%符号。此外,%在每个 处添加一个\end{doc...column}

在此处输入图片描述

例如,可以在这里找到更多信息:删除“虚拟”宏周围的空格

\documentclass[a4paper,12pt]{minimal}

\usepackage[margin={2cm, 1.5cm}]{geometry}
\usepackage{polski}
\usepackage{calc}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}

\tcbset
{
  colback=gray!70,
  arc=0pt,arc=0pt,    
  colframe=blue,
  enhanced,
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
% PARAMETERS                                                                    %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newlength{\marginbetweencolumns}
\newlength{\leftcolumnwidth}
\newlength{\middlecolumnwidth}
\newlength{\rightcolumnwidth}

\setlength{\parindent}{0cm}

\setlength{\marginbetweencolumns}{0mm}
\setlength{\leftcolumnwidth}{5cm}
\setlength{\middlecolumnwidth}{5cm}
\setlength{\rightcolumnwidth}{\textwidth-\leftcolumnwidth-\marginbetweencolumns-\middlecolumnwidth-\marginbetweencolumns}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
% ENVIRONMENTS                                                                  %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newenvironment{docleftcolumn}%
{ %
  \begin{minipage}[t]{\leftcolumnwidth}%
  \vspace{0pt}%
  \begin{tcolorbox}%
}%
{%
  \end{tcolorbox}%
  \end{minipage}%
}

\newenvironment{docmiddlecolumn}%
{%
  \begin{minipage}[t]{\middlecolumnwidth}%
  \vspace{0pt}%
  \begin{tcolorbox}%
}%
{%
  \end{tcolorbox}%
  \end{minipage}%
}

\newenvironment{docrightcolumn}%
{%
  \begin{minipage}[t]{\rightcolumnwidth}%
  \vspace{0pt}%
  \begin{tcolorbox}%
}%
{%
  \end{tcolorbox} % 
  \end{minipage}%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                               %
% DOCUMENT BODY                                                                 %
%                                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{docleftcolumn}
Column 1
\end{docleftcolumn}%
\begin{docmiddlecolumn}
Column 2
\end{docmiddlecolumn}%
\begin{docrightcolumn}
Column 3
\end{docrightcolumn}

\end{document}

答案2

使用tcolorbox,您的代码会变得不必要地复杂和僵化。考虑这个替代方案:

\documentclass[a4paper]{article}
\usepackage[margin={2cm, 1.5cm}]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\begin{document}

\begin{tcbposter}[poster = {%showframe,
height=20cm,columns=12,rows=2,spacing=2mm},
boxes = {colback=gray!10, arc=0pt,arc=0pt, colframe=blue,  enhanced}]
\posterbox{name=A,column=1,row=1,span=4}{\lipsum[1][1-11]}
\posterbox{name=B,column=5,row=1,span=3}{\lipsum[2][1-8]}
\posterbox{name=C,column=8,span=5}{\lipsum[3-4]}
\posterbox{name=D,column=1,row=2,span=3}{\lipsum[4][1-9]}
\posterbox{name=E,column=4,row=2,span=4}{\lipsum[5][1-9]}
\posterbox{name=F,column=8,between=C and bottom,span=5}{\lipsum[6][1-6]}
\end{tcbposter}

\end{document}

姆韦

至于删除框之间的空间,当然,spacing=2mm改为spacing=0mm

相关内容