使文本居中

使文本居中
\documentclass[a4paper, 12pt, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{graphicx}
\usepackage{wrapfig}
%------------------------------ colors
\usepackage[usenames,dvipsnames,table]{xcolor} % use colors on table and more
\definecolor{333}{RGB}{51, 51, 51} % define custom color
%------------------------------ source code
\usepackage{listings}
\lstset{
  basicstyle=\footnotesize\sffamily,
  commentstyle=\itshape\color{gray},
  captionpos=b,
  frame=shadowbox,
  language=HTML,
  rulesepcolor=\color{333},
  tabsize=2
}
%------------------------------ define Abstract environment, missing in the 'book' class
\newenvironment{abstract}{\cleardoublepage \null \vfill \begin{center}\bfseries\abstractname \end{center}}{\vfill\null}
\addto\captionsenglish{\renewcommand*\abstractname{Sommario}} % change Abstract title
%------------------------------ active url
\usepackage{url}
\renewcommand{\UrlFont}{\color{black}\small\ttfamily}
\usepackage[colorlinks=true, linkcolor=black, citecolor=black, urlcolor=black]{hyperref} % active ref
\usepackage{showframe}
%------------------------------ macros
\newcommand{\sectionname}{Section} % define Section ref
\newcommand{\subsectionname}{Sub-section} % define Sub-section ref
\renewcommand*\arraystretch{1.4} % tables padding


\begin{document}
\frontmatter

\begin{titlepage} %------------------------------ TITLE PAGE
\begin{center}
\vbox to0pt{\vbox to\textheight{\vfill \includegraphics[width=11.5cm]{images/unipd-light} \vfill}\vss}

\hspace{0.0cm}
\begin{minipage}[t]{\textwidth}%{.20\textwidth}
  \centering
  \hspace{-0.005cm}\includegraphics[height=2.5cm]{images/logo_unipd}
\end{minipage}
\begin{minipage}{1\textwidth}
    \centering
  \begin{table}[H]
  \begin{tabular}{c}
  \hspace{-0.02cm}\scshape{\Large{\bfseries{Università degli Studi di Padova}}} \\
  %\hline \\
  \vspace{0.2cm}
  \hspace{-0.22cm}\noindent\makebox[\linewidth]{\rule{0.9\textwidth}{0.5pt}}\\
  \hspace{0.027cm}\hspace{-0.43cm}\scshape{\Large{Dipartimento di Ingegenria Industriale DII}} \\
  \end{tabular}
  \end{table}
\end{minipage}

\vspace{0.5cm}
\hspace{-0.09cm}\large{Corso di Laurea Magistrale in Ingegneria dell'Energia Elettrica} \\
\vspace{2.25cm}
\scshape{\Large{\bfseries{Analysis of an innovative distribution system through a novel optimal power flow algorithm}}} 
\end{center}

\vfill
\begin{normalsize}
\begin{flushleft}
  \hspace{57pt} \textit{Laureando} \hspace{167pt} \textit{Relatore}\\
  \vspace{5pt}
  \hspace{30pt} \large{\textbf{Tommaso Faedo}} \hspace{70pt} \large{\textbf{Prof. Roberto Turri}}\\
  \vspace{10pt}
  \hspace{275pt} \normalsize{\textit{Correlatore}}\\
  \vspace{5pt}
  \hspace{241pt} \large{\textbf{Prof. Paolo Tenti}}\\
  \vspace{5pt}
  \hspace{172pt} \large{\textbf{Ing. Tommaso Caldognetto}}\\
\end{flushleft}
\end{normalsize}

\vfill
\begin{center}
\hspace{-0.15cm}
\line(1, 0){360}

\hspace{0.01cm}\textsc{Anno Accademico 2017/2018}
\end{center}
\end{titlepage}


\end{document} 

嗨,这是我的论文封面。我不知道为什么标题或大学的红色徽标等元素没有在主矩形中(主矩形显示论文的边界)居中(垂直)。我添加了 \hspace,但我想知道是否有一个系统可以自动将对象置于中心(垂直)。我尝试使用 \centering,但每次每个元素都没有完全位于主矩形的中心(垂直)。谢谢

答案1

如果我理解正确的话,您希望将文本垂直居中。为此,您应该\vspace*{\fill}在 之后添加一个\begin{titlepage},并\vfill在 之前添加一个\end{titlepage}。(抱歉,如果这不是您的问题。)我还将编码更改为utf8

\documentclass[a4paper, 12pt, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{graphicx}
\usepackage{wrapfig}
%------------------------------ colors
\usepackage[usenames,dvipsnames,table]{xcolor} % use colors on table and more
\definecolor{333}{RGB}{51, 51, 51} % define custom color
%------------------------------ source code
\usepackage{listings}
\lstset{
    basicstyle=\footnotesize\sffamily,
    commentstyle=\itshape\color{gray},
    captionpos=b,
    frame=shadowbox,
    language=HTML,
    rulesepcolor=\color{333},
    tabsize=2
}
%------------------------------ define Abstract environment, missing in the 'book' class
\newenvironment{abstract}{\cleardoublepage \null \vfill \begin{center}\bfseries\abstractname \end{center}}{\vfill\null}
\addto\captionsenglish{\renewcommand*\abstractname{Sommario}} % change Abstract title
%------------------------------ active url
\usepackage{url}
\renewcommand{\UrlFont}{\color{black}\small\ttfamily}
\usepackage[colorlinks=true, linkcolor=black, citecolor=black, urlcolor=black]{hyperref} % active ref
\usepackage{showframe}
%------------------------------ macros
\newcommand{\sectionname}{Section} % define Section ref
\newcommand{\subsectionname}{Sub-section} % define Sub-section ref
\renewcommand*\arraystretch{1.4} % tables padding


\begin{document}
    \frontmatter

    \begin{titlepage} %------------------------------ TITLE PAGE
\vspace*{\fill}

        \begin{center}
            \vbox to0pt{\vbox to\textheight{\vfill \includegraphics[width=11.5cm]{images/unipd-light} \vfill}\vss}

            \hspace{0.0cm}
            \begin{minipage}[t]{\textwidth}%{.20\textwidth}
                \centering
                \hspace{-0.005cm}\includegraphics[height=2.5cm]{images/logo_unipd}
            \end{minipage}
            \begin{minipage}{1\textwidth}
                \centering
                \begin{table}[H]
                    \begin{tabular}{c}
                        \hspace{-0.02cm}\scshape{\Large{\bfseries{Università degli Studi di Padova}}} \\
                        %\hline \\
                        \vspace{0.2cm}
                        \hspace{-0.22cm}\noindent\makebox[\linewidth]{\rule{0.9\textwidth}{0.5pt}}\\
                        \hspace{0.027cm}\hspace{-0.43cm}\scshape{\Large{Dipartimento di Ingegenria Industriale DII}} \\
                    \end{tabular}
                \end{table}
            \end{minipage}

            \vspace{0.5cm}
            \hspace{-0.09cm}\large{Corso di Laurea Magistrale in Ingegneria dell'Energia Elettrica} \\
            \vspace{2.25cm}
            \scshape{\Large{\bfseries{Analysis of an innovative distribution system through a novel optimal power flow algorithm}}} 
        \end{center}

        \vfill
        \begin{normalsize}
            \begin{flushleft}
                \hspace{57pt} \textit{Laureando} \hspace{167pt} \textit{Relatore}\\
                \vspace{5pt}
                \hspace{30pt} \large{\textbf{Tommaso Faedo}} \hspace{70pt} \large{\textbf{Prof. Roberto Turri}}\\
                \vspace{10pt}
                \hspace{275pt} \normalsize{\textit{Correlatore}}\\
                \vspace{5pt}
                \hspace{241pt} \large{\textbf{Prof. Paolo Tenti}}\\
                \vspace{5pt}
                \hspace{172pt} \large{\textbf{Ing. Tommaso Caldognetto}}\\
            \end{flushleft}
        \end{normalsize}

        \vfill
        \begin{center}
            \hspace{-0.15cm}
            \line(1, 0){360}

            \hspace{0.01cm}\textsc{Anno Accademico 2017/2018}
        \end{center}
\vfill
    \end{titlepage}


\end{document} 

答案2

这不是对您的问题的直接回答,而是一个更简单的解决方案:

% arara: frontespizio

\documentclass[a4paper]{book}
\usepackage{frontespizio}

\begin{document}

\begin{frontespizio}
\begin{Preambolo*}
\usepackage[T1]{fontenc}
\renewcommand{\frontinstitutionfont}{\fontsize{14}{17}\bfseries\scshape}
\renewcommand{\fronttitlefont}{\fontsize{17}{21}\bfseries\scshape}
\renewcommand{\frontfootfont}{\fontsize{12}{14}\scshape}
\end{Preambolo*}
\Margini{3cm}{3cm}{3cm}{2cm}
%
\Logo[2.5cm]{../duck}
\Filigrana[height=11.5cm]{../duck}
\Universita{Padova}
\Dipartimento{Ingegneria Industriale DII}
\Corso{Ingegneria dell'Energia Elettrica}
\Titolo{Analysis of an innovative distribution system
        through a novel optimal power flow algorithm}
\NCandidato{Laureando}
\Candidato{Tommaso Faedo}
\Relatore{Prof.\ Roberto Turri}
\Correlatore{Prof.\ Paolo Tenti}
\Correlatore{Ing.\ Tommaso Caldognetto}
\Annoaccademico{2017/2018}
\end{frontespizio}

\end{document}

在此处输入图片描述

相关内容