{multicol} 与 \documentclass[twocolumn]{book}

{multicol} 与 \documentclass[twocolumn]{book}

我已经查看并测试了各种代码,但恐怕我无法弄清楚这一点:如何在页面内将文档的标题、目录、LOT、序言和简介以及我想要居中的文本部分居中?

该文档使用该/multicol包,因此应该能够根据具体情况使某些格式元素出现在页面的正中央(而不是正文的中心)。

我究竟做错了什么?

%preamble
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\usepackage[english]{babel}
\usepackage{tocloft}
\usepackage[nottoc]{tocbibind}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{multicol}
\usepackage{babel}
\usepackage{graphicx}
\graphicspath{ {h:/} }
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage[document]{ragged2e}
\usepackage{eso-pic}
\usepackage{ifthen}
\usepackage{tikz}
%\usepackage{showframe}

\setlength{\columnsep}{8mm}

%Table of Content depth
\geometry{verbose}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{5}
\setlength{\parindent}{0pt}

%Hyperlinks for TOC
\makeatletter
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\makeatother

%Formating Document per Pto-M-cook
\geometry{
    a4paper,
    total={21.59cm,27.94cm},
    top=2.8cm,
    bottom=2.1cm,
    inner=1.91cm,
    outer=6.68cm,
    marginparwidth=4cm,
    marginparsep=0.8cm
}

%\renewcommand{\cfttoctitlefont}{\hfil \Huge}

\begin{document}

\title{A Fantastic Title}
\author{Author's Name}

\maketitle

%To clear empty page before TOC
\let\cleardoublepage\clearpage

\tableofcontents

\listoftables

\section*{Preamble}
\lipsum[75]

\section*{Introduction}
\lipsum[75]

%To clear empty page before Chapter
\let\cleardoublepage\clearpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Following is the code used to create vertical bars between text body and margin

\def\bottommargin{\paperheight - \topmargin - \textheight - \headheight - \headsep - 1in - \voffset}
\def\toptotalheight{\paperheight - \topmargin - \headheight - \headsep - 1in - \voffset}
\def\leftlength{
    \evensidemargin - 0.5*\marginparsep
    + 1in
    + \hoffset
}
\def\rightlength{\paperwidth
    - \evensidemargin + 0.5*\marginparsep
    - 1in - \hoffset}

\makeatletter
\newcommand{\nomarginbar}{\let\ESO@HookIIBG\@empty}
\makeatother

\newcommand{\thisisfullsize}{\path (0,0) --  (\paperwidth,\paperheight);}

\newcommand\LeftBar{%
    \put(0,0){%
        \parbox[b][\paperheight]{\paperwidth}{%
            \vfill
            \centering
            \begin{tikzpicture}
            \thisisfullsize
            \draw[line width=0.4pt] (\leftlength,\bottommargin) -- (\leftlength,\toptotalheight);
            \end{tikzpicture}
            \vfill
}}}

\newcommand\RightBar{% 
    \put(0,0){%
        \parbox[b][\paperheight]{\paperwidth}{%
            \vfill
            \centering
            \begin{tikzpicture}
            \thisisfullsize
            \draw[line width=0.4pt] (\rightlength,\bottommargin) -- (\rightlength,\toptotalheight);
            \end{tikzpicture}
            \vfill
}}}

%%% Use this in two-side documents
\AtBeginShipout{%
    \ifthenelse{\isodd{\value{page}}}%
    {\AddToShipoutPictureBG*{\LeftBar}%
    }%
    {\AddToShipoutPictureBG*{\RightBar}%
    }%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{The First Chapter}

\begin{multicols*}{2}

\section{The First Proper Section}
\lipsum[75]

And now this table:

\begin{table*}
    \centering
    \begin{tabular}{r|c|c|l}
    \hline
    Information & Information & Information & Information\tabularnewline \hline  Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline
    \hline
    \end{tabular}
    \caption{Important Data}
\end{table*}

\marginnote{\lipsum[75]}[3cm]

\lipsum[75]

\subsection{The Subsection}
\lipsum[75]

And now I'm going to list a list of listed things:
\begin{enumerate}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
    \item \lipsum[75]
    \item \lipsum[75]
    \item \lipsum[75]
\end{enumerate}
\lipsum[75]

\subsubsection{A Subsubsection}
\lipsum[75]

\marginnote{\lipsum[75]}[3cm]

\lipsum[75]

%To clear empty page before Chapter
\let\cleardoublepage\clearpage

\chapter{The Second Chapter}

\section{The Second Proper Section}
\lipsum[75]

The image should appear right after this:

%\includegraphics*{universe}

And now, more text to see how this works.

\subsection{The Second Subsection}
\lipsum[75]

\subsubsection{A Second Subsubsection}
\lipsum[75]

\marginnote{\lipsum[75]}[3cm]

\lipsum[75]

\end{multicols*}    
\end{document}

答案1

据我所知,你正在寻找类似的东西

在此处输入图片描述

%preamble
\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\usepackage[english]{babel}
\usepackage{tocloft}
\usepackage[nottoc]{tocbibind}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{multicol}
\usepackage{babel}
\usepackage{graphicx}
\graphicspath{ {h:/} }
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage[document]{ragged2e}
\usepackage{eso-pic}
\usepackage{ifthen}
\usepackage{tikz}
%\usepackage{showframe}

\setlength{\columnsep}{8mm}

%Table of Content depth
\geometry{verbose}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{5}
\setlength{\parindent}{0pt}

%Hyperlinks for TOC
\makeatletter
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\makeatother

%Formating Document per Pto-M-cook
\geometry{
    a4paper,
    total={21.59cm,27.94cm},
    top=2.8cm,
    bottom=2.1cm,
    inner=1.91cm,
    outer=6.68cm,
    marginparwidth=4cm,
    marginparsep=0.8cm
}

%\renewcommand{\cfttoctitlefont}{\hfil \Huge}

\begin{document}

\title{A Fantastic Title}
\author{Author's Name}

\begingroup


\oddsidemargin=0.5\dimexpr\paperwidth-\textwidth-2in\relax
\evensidemargin=\oddsidemargin
\maketitle

%To clear empty page before TOC ???????!!
\let\cleardoublepage\clearpage

\tableofcontents

\listoftables

\section*{Preamble}
\lipsum[75]

\section*{Introduction}
\lipsum[75]

\clearpage
\endgroup
\clearpage

%To clear empty page before chapter ???????!!
\let\cleardoublepage\clearpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Following is the code used to create vertical bars between text body and margin

\def\bottommargin{\paperheight - \topmargin - \textheight - \headheight - \headsep - 1in - \voffset}
\def\toptotalheight{\paperheight - \topmargin - \headheight - \headsep - 1in - \voffset}
\def\leftlength{
    \evensidemargin - 0.5*\marginparsep
    + 1in
    + \hoffset
}
\def\rightlength{\paperwidth
    - \evensidemargin + 0.5*\marginparsep
    - 1in - \hoffset}

\makeatletter
\newcommand{\nomarginbar}{\let\ESO@HookIIBG\@empty}
\makeatother

\newcommand{\thisisfullsize}{\path (0,0) --  (\paperwidth,\paperheight);}

\newcommand\LeftBar{%
    \put(0,0){%
        \parbox[b][\paperheight]{\paperwidth}{%
            \vfill
            \centering
            \begin{tikzpicture}
            \thisisfullsize
            \draw[line width=0.4pt] (\leftlength,\bottommargin) -- (\leftlength,\toptotalheight);
            \end{tikzpicture}
            \vfill
}}}

\newcommand\RightBar{% 
    \put(0,0){%
        \parbox[b][\paperheight]{\paperwidth}{%
            \vfill
            \centering
            \begin{tikzpicture}
            \thisisfullsize
            \draw[line width=0.4pt] (\rightlength,\bottommargin) -- (\rightlength,\toptotalheight);
            \end{tikzpicture}
            \vfill
}}}

%%% Use this in two-side documents
\AtBeginShipout{%
    \ifthenelse{\isodd{\value{page}}}%
    {\AddToShipoutPictureBG*{\LeftBar}%
    }%
    {\AddToShipoutPictureBG*{\RightBar}%
    }%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{The First Chapter}

\begin{multicols*}{2}

\section{The First Proper Section}
\lipsum[75]

And now this table:

\begin{table*}
    \centering
    \begin{tabular}{r|c|c|l}
    \hline
    Information & Information & Information & Information\tabularnewline \hline  Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline
    \hline
    \end{tabular}
    \caption{Important Data}
\end{table*}

\marginnote{\lipsum[75]}[3cm]

\lipsum[75]

\subsection{The Subsection}
\lipsum[75]

And now I'm going to list a list of listed things:
\begin{enumerate}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
    \item \lipsum[75]
    \item \lipsum[75]
    \item \lipsum[75]
\end{enumerate}
\lipsum[75]

\subsubsection{A Subsubsection}
\lipsum[75]

\marginnote{\lipsum[75]}[3cm]

\lipsum[75]

%To clear empty page before chapter ???????!!
\let\cleardoublepage\clearpage

\chapter{The Second Chapter}

\section{The Second Proper Section}
\lipsum[75]

The image should appear right after this:

%\includegraphics*{universe}

And now, more text to see how this works.

\subsection{The Second Subsection}
\lipsum[75]

\subsubsection{A Second Subsubsection}
\lipsum[75]

\marginnote{\lipsum[75]}[3cm]

\lipsum[75]

\end{multicols*}    
\end{document}

相关内容