我正在尝试使用 minipage 来获取一些文本旁边的表格,如下图所示。我阅读了相关主题,但似乎无法将其整合在一起。任何帮助都非常感谢。我对此很陌生,所以如果有人能告诉我我做错了什么,那就太好了。
我收到以下错误:
line 22: Not in outer par mode. \begin{table}[h]
line 22: Undefined control sequence \begin{table}[h]
line 22: Missing number, treated as zero \begin{table}[h]
line 3: Overfull \hbox (2.60513pt too wide) in paragraph
line 23: Overfull \hbox (117.52068pt too wide) in paragraph
line 21: Overfull \hbox (20.2359pt too wide) in paragraph
我知道可以通过在某些行末尾附加 % 来修复 \hbox(可能?)但我不太确定哪些行是合适的。
这是我制作的两个文件的代码。
测试标题.tex
\documentclass[pdftex,12pt,letterpaper]{report}
\usepackage[pdftex]{graphicx}
\newcommand{\labno}{3}
\newcommand{\labtitle}{Fuerzas Hidrostaticas}
\newcommand{\authorname}{Author 1 \\ Author 2 \\ Author 3 \\ Author 4}
\newcommand{\instructor}{Instructor}
\newcommand{\classno}{Laboratorio INGE4010}
\begin{document}
\input{./title.tex}
\end{document}
标题.tex
\begin{titlepage}
\noindent
\includegraphics[width=0.15\textwidth]{UPRMlogo}%
\begin{minipage}[b]{0.7\textwidth}
\centering
Universidad de Puerto Rico \\
Recinto de Mayaguez\\
Departamento de Ingenieria Mecanica
\end{minipage} %
\includegraphics[width=0.15\textwidth]{UPRMlogo}
\vspace*{\stretch{7}}
\begin{center}
\textsc{Laboratorio \#\labno \ \labtitle}
\end{center}
\vspace{\stretch{6}}
\vfill
\begin{minipage}{.2\textwidth} %
\begin{table}[h]
\begin{tabular}{|l|r|}
\hline
\textbf{Partes del Informe} & \multicolumn{1}{c|}{\textbf{Calificación}} \\ \hline
Introducción & /10 \\ \hline
Datos y Cálculos & /20 \\ \hline
Análisis de Resultados & /45 \\ \hline
Conclusiones & /20 \\ \hline
Referencia y Apéndice & /5 \\ \hline
Total & /100 \\ \hline
\end{tabular}
\end{table}
\end{minipage} %
\begin{minipage}{\textwidth} %
\begin{flushright}
\textsc{\authorname \\ \classno \\ \instructor \\ \today}
\end{flushright}
\end{minipage} %
\end{titlepage}
答案1
环境没有必要tabular
位于 内table
。
这是标题页的简化版本:
\documentclass[12pt,letterpaper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[demo]{graphicx}
\newcommand{\labno}{3}
\newcommand{\labtitle}{Fuerzas Hidrostaticas}
\newcommand{\authorname}{Author 1 \\ Author 2 \\ Author 3 \\ Author 4}
\newcommand{\instructor}{Instructor}
\newcommand{\classno}{Laboratorio INGE4010}
\begin{document}
\begin{titlepage}
\centering
\includegraphics[width=0.15\textwidth]{UPRMlogo}%
\begin{minipage}[b]{0.7\textwidth}
\centering
Universidad de Puerto Rico \\
Recinto de Mayaguez\\
Departamento de Ingenieria Mecanica
\end{minipage}%
\includegraphics[width=0.15\textwidth]{UPRMlogo}
\vspace*{\stretch{7}}
\textsc{Laboratorio \#\labno \ \labtitle}
\vspace{\stretch{6}}
\vfill
\begin{tabular}{@{}|l|r|@{}}
\hline
\textbf{Partes del Informe} & \multicolumn{1}{c|}{\textbf{Calificación}} \\ \hline
Introducción & /10 \\ \hline
Datos y Cálculos & /20 \\ \hline
Análisis de Resultados & /45 \\ \hline
Conclusiones & /20 \\ \hline
Referencia y Apéndice & /5 \\ \hline
Total & /100 \\ \hline
\end{tabular}%
\hfill
{\scshape
\begin{tabular}{@{}c@{}}
\authorname \\ \classno \\ \instructor \\ \today
\end{tabular}}
\end{titlepage}
\end{document}
请注意,您不应将pdftex
选项传递给类或包graphicx
。我使用它是demo
因为我没有徽标,所以删除了它。
答案2
我建议使用booktabs
并cellspace
改善表格的外观和间距。不要将其放在表格环境中,因为它不浮动。
\documentclass[pdftex,12pt,letterpaper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[pdftex]{graphicx}
\usepackage{booktabs}
\usepackage{cellspace}
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}
\newcommand{\labno}{3}
\newcommand{\labtitle}{Fuerzas Hidrostaticas}
\newcommand{\authorname}{Author 1 \\ Author 2 \\ Author 3 \\ Author 4}
\newcommand{\instructor}{Instructor}
\newcommand{\classno}{Laboratorio INGE4010}
\begin{document}
\begin{titlepage}
\noindent
\includegraphics[width=0.15\textwidth]{uprm_logo.jpg}%
\begin{minipage}[b]{0.7\textwidth}
\centering
Universidad de Puerto Rico \\
Recinto de Mayaguez\\
Departamento de Ingenieria Mecanica
\end{minipage} %
\includegraphics[width=0.15\textwidth]{logo_upr.png}
\vspace*{\stretch{7}}
\begin{center}
\textsc{Laboratorio \#\labno \ \labtitle}
\end{center}
\vspace{\stretch{6}}
\vfill
\noindent
\begin{minipage}{.2\textwidth}%
\begin{tabular}{@{}Slr@{}}
\toprule
\textbf{Partes del Informe} & \textbf{Calificación} \\
\midrule
Introducción & /10 \\
Datos y Cálculos & /20 \\
Análisis de Resultados & /45 \\
Conclusiones & /20 \\
Referencia y Apéndice & /5 \\
Total & /100 \\
\bottomrule
\end{tabular}
\end{minipage} %
\hfill
\begin{minipage}{0.7\textwidth} %
\begin{flushright}
\textsc{\authorname \\[1ex] \classno \\[1ex] \instructor \\[1ex] \today}
\end{flushright}
\end{minipage}
%
\end{titlepage}
\end{document}