.png)
Ich habe versucht, mehrere Spalten zu verwenden, um die erste Zeile der Tabelle zu zentrieren, und der Rest folgt der normalen Absatzregel. Hier ist der Codeausschnitt:
\documentclass[a4paper,12pt]{report}
\usepackage{indentfirst}
\setlength{\parindent}{2.30em}
\usepackage[utf8]{inputenc}
\usepackage{pdflscape}
\usepackage{lscape}
\usepackage{booktabs, tabularx}
\usepackage{bm}
\usepackage{xfrac}
\usepackage[titles]{tocloft}
\usepackage{subfig}
\usepackage{rotating}
\usepackage{wrapfig}
\usepackage{mathptmx}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{cleveref}
\usepackage[top=1.8in, bottom=1.25in, left=1.75in, right=1.25in, headheight=1.25in]{geometry}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\sloppy
\microtypecontext{spacing=nonfrench}
\emergencystretch=\maxdimen
% Fonts
\usepackage{sectsty}
\allsectionsfont{\normalsize}
%Pagination
\usepackage{fancyhdr}
\pagestyle{fancyplain}% <- use fancyplain instead fancy
\fancyhf{}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
% Caption
\usepackage{caption}
\captionsetup{format=hang, font=normalsize, labelfont=bf, justification=justified, labelsep=period}
% Graphics
\usepackage{graphicx}
\graphicspath{{./Figure/}}
\DeclareGraphicsExtensions{.pdf,.jpeg,.jpg,.png}
% Spacing
\usepackage{setspace} % control linespacing
\setstretch{1.5}
\clearpage
\begin{document}
\renewcommand{\thechapter}{\Roman{chapter}}
\chapter{Methodology}
\renewcommand{\thechapter}{\arabic{chapter}}
\label{ch:Methodology}
\thispagestyle{empty}
\begin{landscape}
\centering
\begin{tabularx}{\linewidth}{| p{0.75in} | p{1in} | p{0.9in} | p{2in} | p{0.8in} | p{0.6in} | p{0.8in} |}{\hyphenpenalty=20\exhyphenpenalty=20}
\hline
\multicolumn{1}{|c|}{\textbf{Name}} & \multicolumn{1}{|c|}{\textbf{Alphanumeric Name}} & \multicolumn{1}{|c|}{\textbf{Fiber Strand Size}} (mm) &
\multicolumn{1}{|c|}{\textbf{Color}} & \multicolumn{1}{|c|}{\textbf{Stripping}} & \multicolumn{1}{|c|}{\textbf{Texture}} &
\multicolumn{1}{|c|}{\textbf{Extracted From}} \\
\hline
Streaky Two & S2 & 0.20 - 0.50 & Ivory white, slightly tinged with very light brown to red or purple streak & Excellent & Soft &
Next to the outer leafsheath \\
\hline
\end{tabularx}
\label{table:Abaca Fiber Grades}
\end{landscape}
\end{document}
Allerdings erhalte ich in der Zeile folgende Fehler \end{tabularx}
:
Wie entferne ich diese Fehler? Ich verstehe nicht, was der Fehler aussagen soll. Ihre Hilfe wird sehr geschätzt. Vielen Dank!
Antwort1
A tabularx
-Typ-Tabellemusshaben Sie mindestens eine X
Spalte vom Typ , damit die Gesamtbreite der Tabelle überhaupt der Zielbreite entsprechen kann. Da Sie außerdem jede einzelne Kopfzelle in einen \multicolumn{1}{c}
Wrapper einschließen, deaktivieren Sie tatsächlich den Zeilenumbruch in den Kopfzellen, was zu einer viel zu breiten Tabelle führt. Mein Rat wäre, die Wrapper nicht zu verwenden – und auch nichtfettgedrucktauch nicht. Oh, und entsorgen Sie unbedingt {\hyphenpenalty=20\exhyphenpenalty=20}
…
Ich möchte Sie außerdem dazu ermutigen, der Tabelle ein offeneres und einladenderes „Aussehen“ zu verleihen, indem Sie alle vertikalen Linien entfernen und horizontale Linien mit ausreichend Abstand verwenden. Sehen Sie sich den folgenden Screenshot an, um einen Vergleich des Gefängniszellenfensters mit dem offenen und einladenden Aussehen zu sehen.
\documentclass[a4paper,12pt]{report}
\usepackage{indentfirst}
\setlength{\parindent}{2.30em} % that's kind of extreme
%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage{pdflscape}
%\usepackage{lscape} %% don't load both lscape and pdflscape
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage{tabularx}
\usepackage{bm}
\usepackage{xfrac}
\usepackage[titles]{tocloft}
\usepackage{subfig}
%%\usepackage{rotating} %% do you need this package?
\usepackage{wrapfig}
\usepackage{amsmath, amssymb} % 'amsfonts' is loaded automatically by 'amssymb'
%\usepackage{mathptmx} % mathptmx is borderline obsolete
\usepackage{newtxtext,newtxmath}
\usepackage{cleveref}
\usepackage[top=1.8in, bottom=1.25in,
left=1.75in, right=1.25in,
headheight=1.25in % this seems excessive
]{geometry}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\microtypecontext{spacing=nonfrench}
%%\sloppy %% <-- a bad idea
%%\emergencystretch=\maxdimen
% Modify styles of sectioning headers
\usepackage{sectsty}
\allsectionsfont{\normalsize}
%Apperance of pages
\usepackage{fancyhdr}
\pagestyle{fancyplain}% <- use fancyplain instead fancy
\fancyhf{}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
% Caption
\usepackage{caption}
\captionsetup{format=hang,
font=normalsize,
labelfont=bf,
justification=justified,
labelsep=period,
skip=0.333\baselineskip}
% Graphics
\usepackage{graphicx}
\graphicspath{{./Figure/}}
\DeclareGraphicsExtensions{.pdf,.jpeg,.jpg,.png}
% Spacing
\usepackage{setspace} % control linespacing
\setstretch{1.5}
%%\clearpage % <-- not needed
%% New
\usepackage{ragged2e} % for '\RaggedRight' macro
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}} % get rid of full justification, allow hyphenation
\newcolumntype{L}{>{\RaggedRight}X} % ditto
\usepackage{calc} % for '\widthof' macro
\begin{document}
% \renewcommand{\thechapter}{\Roman{chapter}}
% \chapter{Methodology}
% \label{ch:Methodology}
%
% \renewcommand{\thechapter}{\arabic{chapter}}
%
% \thispagestyle{empty}
\begin{landscape}
%%\centering % no need for this
\begin{table}
\caption{Abaca Fiber Grades}
\label{table:Abaca_Fiber_Grades}
\begin{tabularx}{\linewidth}%
{| P{\widthof{Streaky Two}} |
P{\widthof{Alphanumeric}} |
P{\widthof{Fiber strand}} |
L |
P{\widthof{Excellent}} |
P{\widthof{Texture}} |
P{1.1in} |}
%\hyphenpenalty=20\exhyphenpenalty=20 % huh??
\hline
Name &
Alphanumeric name &
Fiber strand size (mm) &
Color &
Stripping & % 'Stripping' or 'Striping'?
Texture &
Extracted from \\
\hline
Streaky Two &
S2 &
0.20--0.50 &
Ivory white, slightly tinged with very light brown to red or purple streak &
Excellent &
Soft &
Next to the outer leafsheath \\
\hline
\end{tabularx}
\vspace*{1.5cm}
\caption{Same table, but (i) without vertical rules and (ii) with well-spaced horizontal rules}
\begin{tabularx}{\linewidth}%
{@{} P{\widthof{Streaky Two}}
P{\widthof{Alphanumeric}}
P{\widthof{Fiber strand}}
L
P{\widthof{Excellent}}
P{\widthof{Texture}}
P{1.1in} @{}}
%\hyphenpenalty=20\exhyphenpenalty=20 % huh?
\toprule
Name &
Alphanumeric name &
Fiber strand size (mm) &
Color &
Stripping & % 'Stripping' or 'Striping'?
Texture &
Extracted from \\
\midrule
Streaky Two &
S2 &
0.20--0.50 &
Ivory white, slightly tinged with very light brown to red or purple streak &
Excellent &
Soft &
Next to the outer leafsheath \\
\bottomrule
\end{tabularx}
\end{table}
\end{landscape}
\end{document}