
Edición 1: la imagen debe ser "Tres líneas en lugar de cuatro".
Edición 2: Código compilable actualizado.
Soy nuevo en Latex y tengo el siguiente código de plantilla que proporciona un título para mi tesis:
\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided
\usepackage{graphicx}
\usepackage[ngerman,american]{babel}
\newcommand*{\getUniversity}{University of Earth}
\newcommand*{\getFaculty}{Engineering Department}
\newcommand*{\getDegree}{Computer Science}
\newcommand*{\getSchool}{School of Public Science}
\newcommand*{\getTitle}{This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break}
\newcommand*{\getTitleGer}{This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break}
\newcommand*{\getAuthor}{Author}
\newcommand*{\getDoctype}{Thesis}
\newcommand*{\getSupervisor}{Faculty Professor}
\newcommand*{\getAdvisor}{Faculty Advisr}
\newcommand*{\getSubmissionDate}{\today}
\newcommand*{\getSubmissionLocation}{Somewhere In between}
\begin{document}
\begin{titlepage}
\centering
\includegraphics[height=20mm]{example-image-a}
\vspace{5mm}
{\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}
\vspace{5mm}
{\large\MakeUppercase{\getUniversity{}} \par}
\vspace{20mm}
% \vspace{6mm}
{\Large \getDoctype{} in \getDegree{} \par}
\vspace{15mm}
% \vspace{4mm}
{\huge\bfseries \getTitle{} \par}
\vspace{5mm}
{\huge\bfseries \foreignlanguage{ngerman}{\getTitleGer{}} \par}
\vspace{10mm}
\begin{tabular}{l l}
Author: & \getAuthor{} \\
Supervisor: & \getSupervisor{} \\
Advisors: & \getAdvisor{} \\
Submission Date: & \getSubmissionDate{} \\
\end{tabular}
\vfill{}
\includegraphics[height=15mm]{example-image-b}
\end{titlepage}
\end{document}
Tengo dos preguntas:
¿Hay alguna manera de aumentar el margen de la línea para la parte \getTitle{}? Quiero mantener el tamaño de fuente y la especificación vspace{}. A medida que el título se alarga, tiende a dividirse en 3 o 4 líneas muy rápidamente. Quiero estirarlo para que tenga alrededor de 2 o 3 líneas.
En caso de que el título sea demasiado largo, la parte de autoría y la final
faculty_logo
(Ejemplo de imagen B en el fragmento de código) se dividirán en la página siguiente. ¿Hay alguna manera de arreglar siempre estos dos componentes en la parte inferior de la página sin pasar a la página siguiente?
En general, quiero 2 títulos, cada uno con 3 líneas de la misma longitud de texto definida en el fragmento de código, y todo debería permanecer en la misma página.
Respuesta1
Probablemente sea suficiente una macro que produzca un \parbox
resultado que sobresalga en los márgenes:
\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided
%---------------------------------------------------------
\newsavebox\scratchbox
\newcommand\boxIntoMargins[4]{%
\savebox\scratchbox{%
\mbox{%
\kern-\dimexpr(#1)\relax
\parbox[b]{\dimexpr((#1)+(#2)+(#3))\relax}{#4}%
}%
}%
\wd\scratchbox=\linewidth
\usebox\scratchbox
}%
%---------------------------------------------------------
\usepackage{graphicx}
\usepackage[ngerman,american]{babel}
\newcommand*{\getUniversity}{University of Earth}
\newcommand*{\getFaculty}{Engineering Department}
\newcommand*{\getDegree}{Computer Science}
\newcommand*{\getSchool}{School of Public Science}
\newcommand*{\getTitle}{%
\boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
\centering
This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
}%
}
\newcommand*{\getTitleGer}{%
\boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
\centering
This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
}%
}
\newcommand*{\getAuthor}{Author}
\newcommand*{\getDoctype}{Thesis}
\newcommand*{\getSupervisor}{Faculty Professor}
\newcommand*{\getAdvisor}{Faculty Advisr}
\newcommand*{\getSubmissionDate}{\today}
\newcommand*{\getSubmissionLocation}{Somewhere In between}
\begin{document}
\begin{titlepage}
\centering
\includegraphics[height=20mm]{example-image-a}
\vspace{5mm}
{\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}
\vspace{5mm}
{\large\MakeUppercase{\getUniversity{}} \par}
\vspace{20mm}
% \vspace{6mm}
{\Large \getDoctype{} in \getDegree{} \par}
\vspace{15mm}
% \vspace{4mm}
{\huge\bfseries \getTitle{} \par}
\vspace{5mm}
{\huge\bfseries \foreignlanguage{ngerman}{\getTitleGer{}} \par}
\vspace{10mm}
\begin{tabular}{l l}
Author: & \getAuthor{} \\
Supervisor: & \getSupervisor{} \\
Advisors: & \getAdvisor{} \\
Submission Date: & \getSubmissionDate{} \\
\end{tabular}
\vfill{}
\includegraphics[height=15mm]{example-image-b}
\end{titlepage}
\end{document}
Captura de pantalla de la compilación usando Overleaf:
En un comentario complementario se planteó la siguiente pregunta:
Olvidé volver a ajustar el valor predeterminado de la plantilla. La altura de la imagen b debe ser de 20 mm, lo que aún pasa a la segunda página. ¿Hay alguna manera de mantenerlo siempre en una página?
El autor de la publicación inicial de esta respuesta supone que no hay manera de mantener siempre las cosas en una sola página, ya que la condición de tener demasiado texto para caber en una sola página siempre se puede cumplir con solo tener más texto. ;-) Y cree que tratar de automatizar los ajustes para aumentar las posibilidades de que quepan en una sola página podría no valer la pena.
Probablemente podría colocar el contenido de la página de título en un lugar separado \newsavebox
donde las cosas puedan exceder las medidas del papel y combinar el uso del comando \scalebox
del paquete graphicxs y el comando \usebox
para reducir la escala del cuadro para que quepa en el papel.
O tenga la página de título en un documento .tex separado a partir del cual se creará un archivo .pdf separado, que a su vez se incluirá en su documento principal mediante \includegraphics
el cual se puede reducir la escala para ajustarse al tamaño del papel del documento principal. estar hecho. Dentro del documento .tex separado, se envía una caja que contiene la página de título que excede las medidas del papel de su documento después de ajustar el \(pdf)pagewidth
y \(pdf)pageheight
.
Lo siguiente podría ser un resumen de cómo abordar el asunto de esta manera:
\documentclass{article}
\newbox\BoxWithTitlepage
\newcommand\ShipoutAsPage[1]{%
\begingroup
\setbox\BoxWithTitlepage=\vbox{%
\hrule height 0pt
#1\ifvmode\else\expandafter\endgraf\fi
\hrule height 0pt
}%
\csname @ifundefined\endcsname{pagewidth}{}{\pagewidth=\wd\BoxWithTitlepage}%
\csname @ifundefined\endcsname{pdfpagewidth}{}{\pdfpagewidth=\wd\BoxWithTitlepage}%
\csname @ifundefined\endcsname{pageheight}{}{\pageheight=\ht\BoxWithTitlepage
\advance\pageheight\dp\BoxWithTitlepage}%
\csname @ifundefined\endcsname{pdfpageheight}{}{\pdfpageheight=\ht\BoxWithTitlepage
\advance\pdfpageheight\dp\BoxWithTitlepage}%
\shipout\vbox{\kern-1truein\hbox{\kern-1truein\box\BoxWithTitlepage}}%
\endgroup
}%
\begin{document}
\ShipoutAsPage{%
% Content of your titlepage
% Content of your titlepage
% Content of your titlepage
% Content of your titlepage
}%
\end{document}
Pero hay buenas razones por las que esto realmente no se puede recomendar:
- De esta manera no es fácil tener hipervínculos desde la página de título a algún otro lugar del documento.
- La escala no se verá bien porque las fuentes ya no tienen sus tamaños naturales.
- Las reglas/líneas, por ejemplo, de tablas o de imágenes creadas con el
tikzpicture
entorno y similares, pueden volverse demasiado delgadas al escalar las cosas a un tamaño más pequeño y, por lo tanto, es posible que no se puedan imprimir.
Por lo tanto, probablemente sea mejor modificar las cosas "a mano", por ejemplo, ampliando un poco el área tipográfica de la página de título hacia la parte inferior del documento y también modificando el interletraje un poco hacia arriba. La siguiente es una solución "rápida y sucia", pero probablemente podría cumplir el propósito:
\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided
%---------------------------------------------------------
\newsavebox\scratchbox
\newcommand\boxIntoMargins[4]{%
\savebox\scratchbox{%
\mbox{%
\kern-\dimexpr(#1)\relax
\parbox[b]{\dimexpr((#1)+(#2)+(#3))\relax}{#4}%
}%
}%
\wd\scratchbox=\linewidth
\usebox\scratchbox
}%
%---------------------------------------------------------
\usepackage{graphicx}
\usepackage[ngerman,american]{babel}
\newcommand*{\getUniversity}{University of Earth}
\newcommand*{\getFaculty}{Engineering Department}
\newcommand*{\getDegree}{Computer Science}
\newcommand*{\getSchool}{School of Public Science}
\newcommand*{\getTitle}{%
\boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
\centering
This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
}%
}
\newcommand*{\getTitleGer}{%
\boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
\centering
This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
}%
}
\newcommand*{\getAuthor}{Author}
\newcommand*{\getDoctype}{Thesis}
\newcommand*{\getSupervisor}{Faculty Professor}
\newcommand*{\getAdvisor}{Faculty Advisr}
\newcommand*{\getSubmissionDate}{\today}
\newcommand*{\getSubmissionLocation}{Somewhere In between}
\begin{document}
\begin{titlepage}
\enlargethispage{1cm}%
\hrule height 0mm
\kern-.5cm
\centering
\includegraphics[height=20mm]{example-image-a}
\vspace{5mm}
{\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}
\vspace{5mm}
{\large\MakeUppercase{\getUniversity{}} \par}
\vspace{20mm}
% \vspace{6mm}
{\Large \getDoctype{} in \getDegree{} \par}
\vspace{15mm}
% \vspace{4mm}
{\huge\bfseries \getTitle{} \par}
\vspace{5mm}
{\huge\bfseries \foreignlanguage{ngerman}{\getTitleGer{}} \par}
\vspace{10mm}
\begin{tabular}{l l}
Author: & \getAuthor{} \\
Supervisor: & \getSupervisor{} \\
Advisors: & \getAdvisor{} \\
Submission Date: & \getSubmissionDate{} \\
\end{tabular}
\vfill{}
\includegraphics[height=20mm]{example-image-b}
\end{titlepage}
\end{document}
En caso de que la relación ⟨altura-del-margen-superior⟩:⟨altura-del-margen-inferior⟩ no sea 1:1, es posible que deba hacer un poco más de cálculo para garantizar que con el interletraje vertical hacia arriba mientras se amplía el área de tipo hacia abajo esa relación todavía se conserva.
En caso de que la relación ⟨ancho-de-margen-a-la-izquierda⟩:⟨ancho-de-margen-a-la-derecha⟩ no sea 1:1, es posible que deba hacer un poco más de cálculo para asegurarse de que con
\boxIntoMargins{<amount of horizontal space that sticks into left margin>}%
{\linewidth}%
{<amount of horizontal space that sticks into right margin>}%
{...}%
esa proporción se conserva.
Probablemente con la línea
{\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}
podría verse bien cuando las cosas están dispuestas de modo que en caso de que se produzca un salto de línea justo antes del primer guión largo, y toda la cadena que denota la facultad encaje en una sola línea por sí sola. Se agrega un guión detrás \getFaculty{}
para que la cadena de facultad quede anidada entre dos guiones. ;-)
Por cierto: el código de tu ejemplo me recuerdaPortada y página de título con scrbook con página vacía no deseada después de la página de título. Probablemente encuentre allí alguna información útil.