
我正在嘗試使用 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}