我正在尝试将新闻稿的左侧内容放在我的页面上。查看了许多 stackexchange 页面,我尝试使用 wrapfigure+minipage,但无法让文本换行!
\documentclass{article}
\RequirePackage{titlesec}
\RequirePackage{color}
\RequirePackage[table]{xcolor}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{titletoc}
\usepackage{tocloft}
\usepackage{wrapfig}
\usepackage[framemethod=TikZ]{mdframed}% Required for creating boxes
\mdfdefinestyle{sidebar}{
linecolor=gray, % Outer line color
outerlinewidth=0.0pt, % Outer line width
roundcorner=0pt, % Amount of corner rounding
backgroundcolor=gray, % Box background color
frametitlebackgroundcolor=white, % Title background color
frametitlerule=false, % Title rule - true or false
frametitlefont=\Large, % Title heading font specification
font=\small
}
\textwidth = 7 in % Text width
\textheight = 10 in % Text height
\oddsidemargin = -18pt % Left side margin on odd pages
\evensidemargin = -18pt % Left side margin on even pages
\topmargin = -36pt % Top margin
\headheight = 0pt % Remove the header by setting its space to 0
\headsep = 0pt % Remove the space between the header and top of the page
\parskip = 4pt % Space between paragraph
\parindent = 0.0in % Paragraph indentation
\pagestyle{empty} % Disable page numbering
%--------------------------------
% Table of Contents
%--------------------------------
\let\Contentsline\contentsline
\renewcommand\contentsline[3]{\Contentsline{#1}{#2}{}}
\renewcommand{\contentsname}{\hypertarget{contents}{\textbf{{\large In This Issue\ldots}}}}
\makeatletter
\renewcommand{\@seccntformat}[1]{%
\ifcsname prefix@#1\endcsname
\csname prefix@#1\endcsname
\else
\csname the#1\endcsname\quad
\fi}
% define \prefix@section
\newcommand\prefix@section{}
\makeatother
\titlecontents{section}[0em]
{\vskip 0.5ex}%
{\scshape}% numbered sections formattin
{\itshape}% unnumbered sections formatting
{}%
%\setlength\cftaftertoctitleskip{0pt}
\begin{document}
\begin{wrapfigure}{l}{0.3\linewidth}
\begin{minipage}[t]{\linewidth} % Mini page taking up 30% of the actual page
\begin{mdframed}[style=sidebar,frametitle={}] % Sidebar box
\tableofcontents
FOOBAR
\end{mdframed}
\end{minipage}%\hfill % End the sidebar mini page
\end{wrapfigure}
\section{First section} \lipsum[1-2]
\section{Second section} \lipsum[3-4]
\section{Third section} \lipsum[5-6]
\section{Fourth section} \lipsum[7-8]
\section{Fifth section} \lipsum[9-10]
\section{Final section} \lipsum[11-12]
\end{document}
答案1
最好在这里给出wrapfig
比节标题更简单的东西作为开始\mbox{}
。我还删除了minipage
包装图内部,因为我看不出它的目的是什么。
\documentclass{article}
\RequirePackage{titlesec}
\RequirePackage{color}
\RequirePackage[table]{xcolor}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{titletoc}
\usepackage{tocloft}
\usepackage{wrapfig}
\usepackage[framemethod=TikZ]{mdframed}% Required for creating boxes
\mdfdefinestyle{sidebar}{
linecolor=gray, % Outer line color
outerlinewidth=0.0pt, % Outer line width
roundcorner=0pt, % Amount of corner rounding
backgroundcolor=gray, % Box background color
frametitlebackgroundcolor=white, % Title background color
frametitlerule=false, % Title rule - true or false
frametitlefont=\Large, % Title heading font specification
font=\small
}
\textwidth = 7 in % Text width
\textheight = 10 in % Text height
\oddsidemargin = -18pt % Left side margin on odd pages
\evensidemargin = -18pt % Left side margin on even pages
%\topmargin = -36pt % Top margin
%\headheight = 0pt % Remove the header by setting its space to 0
%\headsep = 0pt % Remove the space between the header and top of the page
\parskip = 4pt % Space between paragraph
\parindent = 0.0in % Paragraph indentation
\pagestyle{empty} % Disable page numbering
%--------------------------------
% Table of Contents
%--------------------------------
\let\Contentsline\contentsline
\renewcommand\contentsline[3]{\Contentsline{#1}{#2}{}}
\renewcommand{\contentsname}{\hypertarget{contents}{\textbf{{\large In This Issue\ldots}}}}
\makeatletter
\renewcommand{\@seccntformat}[1]{%
\ifcsname prefix@#1\endcsname
\csname prefix@#1\endcsname
\else
\csname the#1\endcsname\quad
\fi}
% define \prefix@section
\newcommand\prefix@section{}
\makeatother
\titlecontents{section}[0em]
{\vskip 0.5ex}%
{\scshape}% numbered sections formattin
{\itshape}% unnumbered sections formatting
{}%
%\setlength\cftaftertoctitleskip{0pt}
\begin{document}
\begin{wrapfigure}[10]{l}{0.3\linewidth}
\begin{mdframed}[style=sidebar,frametitle={}] % Sidebar box
\tableofcontents
FOOBAR
\end{mdframed}
\end{wrapfigure}
\mbox{}
\section{First section} \lipsum[1-2]
\section{Second section} \lipsum[3-4]
\section{Third section} \lipsum[5-6]
\section{Fourth section} \lipsum[7-8]
\section{Fifth section} \lipsum[9-10]
\section{Final section} \lipsum[11-12]
\end{document}