定心台未完全居中

定心台未完全居中

我的 LaTeX-Fu 很弱。我在尝试创建一个两行三列的表格时遇到了一些问题,所有表格都居中对齐,大小相同,主表格也居中

以下是我所拥有的: 桌子偏离中心

错误如下:第一行(“JAM”)居中,但未与下方的表格对齐。哪一个是正确的?我怀疑表格偏离了中心。其次,在将颜色更改为黑色时,数字(“0800 123456”)添加了换行符。第三,行

\begin{tabular}{>{\centering}p{5.2cm}>{\centering}p{5.2cm}>{\centering}p{5.2cm}}

非常丑陋,但我尝试了很多排列方式让所有单元格以 5.2 厘米为中心,但无济于事。

% document class
\documentclass[a4paper,11pt,final]{memoir}

%set pdf to print transparency properly
\pdfminorversion 7

% stuff
\pagestyle{empty} % no page numbering
\setlength{\parindent}{0pt}     % no paragraph indentation

% required packages (add your own)
\usepackage[default,osfigures,scale=0.95]{opensans} %% Alternatively
\usepackage[T1]{fontenc}
\usepackage[top=2.5cm,left=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}% margins
\usepackage[svgnames]{xcolor} % Call colours by their svgnames


% define custom colours
% Main colour for headers and name
\definecolor{ColourPrimary}{RGB}{54, 99, 169}
\definecolor{ColourBlack}{RGB}{0,0,0}

% Start The Fans Please!
\begin{document}
\fontsize{11}{13} % normal font size
\usefont{OT1}{phv}{b}{n}% HEADING
\color{ColourPrimary}

\begin{center}
JAM
\begin{tabular}{>{\centering}p{5.2cm}>{\centering}p{5.2cm}>{\centering}p{5.2cm}}
CREAM & JAM & BEEF
\tabularnewline
\color{ColourBlack}
\fontsize{11}{13} % normal font size
\usefont{OT1}{phv}{m}{n} %normal
%PHONE
0800 123456
& spoon
& bananas
\end{tabular}
\end{center}

\end{document}

答案1

我必须承认我不太理解你的代码的大部分目的...所以我只局限于表格问题,即表格单元格内容的居中。为此我建议如下:

  • 为了避免表格宽度问题,我将根据文档计算列宽\textwidth

    \begin{tabular}{*{3}{>{\centering\arraybackslash}p{\dimexpr0.33\linewidth-2\tabcolsep}}}
    
  • 使用color{ColourBlack}更改一个单元格中的文本颜色会导致单元格中文本的垂直对齐不匹配。你应该使用它\textcolor{ColourBlack}{<cell's content>}

您的表格的真正 mwe(最小工作示例)是:

\documentclass[a4paper,11pt,final]{memoir}
\usepackage[svgnames]{xcolor}
\definecolor{ColourPrimary}{RGB}{54, 99, 169}
\definecolor{ColourBlack}{RGB}{0,0,0}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%


\begin{document}
\color{ColourPrimary}
    \begin{center}
JAM

\begin{tabular}{*{3}{>{\centering\arraybackslash}p{\dimexpr0.33\linewidth-2\tabcolsep}}}
CREAM       & JAM       & BEEF      \\
\textcolor{ColourBlack}{\usefont{OT1}{phv}{m}{n}    % normal
0800 123456                                         % PHONE
                        }
            & spoon     & bananas
\end{tabular}
    \end{center}
\end{document}

产生以下结果:

在此处输入图片描述

答案2

您的表格太大:

% document class
\documentclass[a4paper,11pt,final]{memoir}

%set pdf to print transparency properly
\pdfminorversion 7

% stuff
\pagestyle{empty} % no page numbering
\setlength{\parindent}{0pt}     % no paragraph indentation

% required packages (add your own)
\usepackage[default,osfigures,scale=0.95]{opensans} %% Alternatively
\usepackage[T1]{fontenc}
\usepackage[top=2.5cm,left=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}% margins
\usepackage[svgnames]{xcolor} % Call colours by their svgnames

\usepackage{showframe}


% define custom colours
% Main colour for headers and name
\definecolor{ColourPrimary}{RGB}{54, 99, 169}
\definecolor{ColourBlack}{RGB}{0,0,0}

% Start The Fans Please!
\begin{document}
\fontsize{11}{13} % normal font size
\usefont{OT1}{phv}{b}{n}% HEADING
\color{ColourPrimary}

\begin{center}
JAM
\begin{tabular}{|>{\centering}p{5.2cm}>{\centering}p{5.2cm}>{\centering}p{5.2cm}|}
CREAM & JAM & BEEF
\tabularnewline
\color{ColourBlack}
\fontsize{11}{13} % normal font size
\usefont{OT1}{phv}{m}{n} %normal
%PHONE
0800 123456
& spoon
& bananas
\end{tabular}


JAM

\begin{tabular}{|>{\centering}p{4.2cm}>{\centering}p{4.2cm}>{\centering}p{4.2cm}|}
CREAM & JAM & BEEF
\tabularnewline
\color{ColourBlack}
\fontsize{11}{13} % normal font size
\usefont{OT1}{phv}{m}{n} %normal
%PHONE
0800 123456
& spoon
& bananas
\end{tabular}

\end{center}

\end{document}

在此处输入图片描述

相关内容