嘿,当我创建表格时,我无法将最后一行,即我的“源行”放在表格左下方。
有人能帮忙吗,我试过移动代码行并尝试添加
\noindent
但我不知道该怎么做
\documentclass[a4paper,article]{memoir}
\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage{booktabs}
\usepackage{tabularx}
\newcommand{\rot}[2]{\rule{1em}{0pt}%
\makebox[0cm][c]{\rotatebox{#1}{\ #2}}}
\pagestyle{plain}
\begin{document}
\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {15cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule
& \multicolumn{8}{c}{\textbf{Værdipolitik}} \\
\textbf{Social Tillid}&\rot{30}{\textbf{Højreorienteret}}&\rot{30}{\textbf{Central orienteret}}&\rot{30}{\textbf{Venstreorienteret}}&\rot{30}{\textbf{Total}}&\rot{30}{\textbf{Højreorienteret}}&\rot{30}{\textbf{Central orienteret}}&\rot{30}{\textbf{Venstreorienteret}}&\rot{30}{\textbf{Total}} \\
&Antal&Antal&Antal&Antal&Kum \%&Kum \%&Kum \%&Kum \% \\
\midrule
Høj tillid&7&50&105&162&43.8\%&65.8\%&84.0\%&74.7\% \\
Moderat tillid&9&23&19&51&100.0\%&96.1\%&99.2\%&98.2\% \\
Lav tillid&0&3&1&4&100.0\%&100.0\%&100.0\%&100.0\% \\
\textbf{Total}&16&76&125&217&&&& \\
\midrule
\textbf{N}&16&76&125&217&&&& \\
\bottomrule
\addlinespace[.75ex]
\end{tabularx}
\par
\scriptsize{\emph{Source: }Kvant Projekt 2016}
\normalsize
\end{center}
如果有人能看到我遗漏了什么,我将不胜感激
提前致谢
答案1
您声明的列太多了。
\documentclass[a4paper,article]{memoir}
\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{graphicx}
\newcommand{\rot}[2]{%
\makebox[0cm][l]{\hspace{-.5em}\rotatebox[origin=bl]{#1}{\ #2}}}
\pagestyle{plain}
\begin{document}
\begin{center}
\footnotesize\addtolength{\tabcolsep}{-2pt}
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {\textwidth} {@{} l *{8}{Y} @{}} \\
\toprule
& \multicolumn{8}{c}{\textbf{Værdipolitik}} \\
\textbf{Social Tillid}&
\rot{30}{\textbf{Højreorienteret}}\hfill\null&
\rot{30}{\textbf{Central orienteret}}\hfill\null&
\rot{30}{\textbf{Venstreorienteret}}\hfill\null&
\rot{30}{\textbf{Total}}\hfill\null&
\rot{30}{\textbf{Højreorienteret}}\hfill\null&
\rot{30}{\textbf{Central orienteret}}\hfill\null&
\rot{30}{\textbf{Venstreorienteret}}\hfill\null&
\rot{30}{\textbf{Total}}\hfill\null \\
&Antal&Antal&Antal&Antal&Kum \%&Kum \%&Kum \%&Kum \% \\
\midrule
Høj tillid & 7 & 50 & 105 & 162 & 43.8\% & 65.8\% & 84.0\% & 74.7\% \\
Moderat tillid & 9 & 23 & 19 & 51 & 100.0\% & 96.1\% & 99.2\% & 98.2\% \\
Lav tillid & 0 & 3 & 1 & 4 & 100.0\% & 100.0\% & 100.0\% & 100.0\% \\
\textbf{Total} & 16 & 76 & 125 & 217 \\
\midrule
\textbf{N} & 16 & 76 & 125 & 217 \\
\bottomrule
\addlinespace[.75ex]
\multicolumn{9}{@{}r@{}}{\scriptsize\emph{Source:} Kvant Projekt 2016}\\
\end{tabularx}
\end{center}
\end{document}
答案2
移出\scriptsize{\emph{Source: }Kvant Projekt 2016}
居中环境并注意\scriptsize
没有参数 - 只需将其放在括号内。
\documentclass[a4paper,article]{memoir}
\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage{booktabs}
\usepackage{graphicx,tabularx}
\newcommand{\rot}[2]{\rule{1em}{0pt}%
\makebox[0cm][c]{\rotatebox{#1}{\ #2}}}
\pagestyle{plain}
\begin{document}
{\centering
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {15cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule
& \multicolumn{8}{c}{\textbf{Værdipolitik}} \\
\textbf{Social Tillid}&\rot{30}{\textbf{Højreorienteret}}&\rot{30}{\textbf{Central orienteret}}&\rot{30}{\textbf{Venstreorienteret}}&\rot{30}{\textbf{Total}}&\rot{30}{\textbf{Højreorienteret}}&\rot{30}{\textbf{Central orienteret}}&\rot{30}{\textbf{Venstreorienteret}}&\rot{30}{\textbf{Total}} \\
&Antal&Antal&Antal&Antal&Kum \%&Kum \%&Kum \%&Kum \% \\
\midrule
Høj tillid&7&50&105&162&43.8\%&65.8\%&84.0\%&74.7\% \\
Moderat tillid&9&23&19&51&100.0\%&96.1\%&99.2\%&98.2\% \\
Lav tillid&0&3&1&4&100.0\%&100.0\%&100.0\%&100.0\% \\
\textbf{Total}&16&76&125&217&&&& \\
\midrule
\textbf{N}&16&76&125&217&&&& \\
\bottomrule
\addlinespace[.75ex]
\end{tabularx}
}
{\scriptsize\emph{Source: }Kvant Projekt 2016}
\end{document}
答案3
您的表格溢出到边距。我建议使用基于xparse
和的代码threeparttable
。我定义了一个 \myrothead
命令,带有一个可选参数,用于移动其单元格中旋转文本开头的水平位置(默认值:1.2em)。必须使用命令手动设置与上一行的垂直间距\addlinespace[xxx]
。我删除了%
单元格中的,因为它们已经在列标题中找到。
\documentclass[a4paper,article]{memoir}
\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate, rotating, graphicx}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage[flushleft, online]{threeparttable}%
\usepackage{xparse}%
\DeclareExpandableDocumentCommand\myrothead{O{1.2em} m m}{\multicolumn{1}{l}{\protect\hspace{#1}\turnbox{#2}{\textbf{#3}}}}
\pagestyle{plain}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.3pt}
\begin{document}
\begin{table}
\footnotesize\centering
\setlength\tabcolsep{3pt}
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{threeparttable}
\begin{tabularx} {\textwidth} {@{} l*{8}{Y}@{}} \\
\toprule
& \multicolumn{8}{c}{\textbf{Værdipolitik}} \\
\addlinespace[12ex]
\textbf{Social Tillid}&\myrothead{30}{Højreorienteret}&\myrothead{30}{Central orienteret}&\myrothead{30}{Venstreorienteret}& \myrothead{30}{Total} &\myrothead[0.6em]{30}{Højreorienteret}&\myrothead[0.6em]{30}{Central orienteret} & \myrothead[0.6em]{30}{Venstreorienteret} &\myrothead[0.6em]{30}{Total} \\
&Antal&Antal&Antal&Antal& Kum\,\% & Kum\,\% & Kum\,\% & Kum\,\% \\
\midrule
Høj tillid&7&50&105&162& 43.8 & 65.8&84.0 &74.7 \\
Moderat tillid&9&23&19&51&100.0 &96.1 &99.2 &98.2 \\
Lav tillid&0&3&1&4&100.0 &100.0 &100.0 &100.0 \\
\addlinespace
\textbf{Total}&16&76&125&217&&&& \\
\midrule
\textbf{N}&16&76&125&217&&&& \\
\bottomrule
\addlinespace[.75ex]
\end{tabularx}
\begin{tablenotes}[flushleft, online]
\scriptsize
\item[\emph{Source:}] Kvant Projekt 2016.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}