Latex:用引号将文本环绕在框内

Latex:用引号将文本环绕在框内

下面的代码代表我的论文报告的画布。我对引用位置有问题。

\documentclass[a4paper,11pt, oldfontcommands]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[english, frenchb]{babel}
\usepackage[a4paper]{geometry}
\usepackage{wrapfig}
\usepackage{ragged2e}
\usepackage{lipsum}
%%% code from http://www.ceus-now.com/block-quote-with-big-quotation-marks/
\usepackage{ifxetex,ifluatex}
\usepackage{etoolbox}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{framed}
% conditional for xetex or luatex
\newif\ifxetexorluatex
\ifxetex
 \xetexorluatextrue
\else
\ifluatex
 \xetexorluatextrue
 \else
 \xetexorluatexfalse
 \fi
\fi
%
 \ifxetexorluatex%
 \usepackage{fontspec}
  \usepackage{libertine} % or use \setmainfont to choose any font on your system
  \newfontfamily\quotefont[Ligatures=TeX]{Linux Libertine O} % selects Libertine as the quote font
\else
  \usepackage[utf8]{inputenc}
  \usepackage[T1]{fontenc}
  \usepackage{libertine} % or any other font package
  \newcommand*\quotefont{\fontfamily{LinuxLibertineT-LF}} % selects Libertine as the quote font
\fi

\newcommand*\quotesize{40} % if quote size changes, need a way to make shifts relative
% Make commands for the quotes
\newcommand*{\openquote}
   {\tikz[remember picture,overlay,xshift=-4ex,yshift=-2.5ex]
   \node (OQ) {\quotefont\fontsize{\quotesize}    {\quotesize}\selectfont``};\kern0pt}

\newcommand*{\closequote}[1]
  {\tikz[remember picture,overlay,xshift=4ex,yshift={#1}]
   \node (CQ) {\quotefont\fontsize{\quotesize}{\quotesize}\selectfont''};}

% select a colour for the shading
\colorlet{shadecolor}{Gray}

\newcommand*\shadedauthorformat{\emph} % define format for the author argument

% Now a command to allow left, right and centre alignment of the author
\newcommand*\authoralign[1]{%
  \if#1l
    \def\authorfill{}\def\quotefill{\hfill}
  \else
    \if#1r
      \def\authorfill{\hfill}\def\quotefill{}
    \else
      \if#1c
        \gdef\authorfill{\hfill}\def\quotefill{\hfill}
      \else\typeout{Invalid option}
      \fi
    \fi
  \fi}
% wrap everything in its own environment which takes one argument (author) and one optional argument
% specifying the alignment [l, r or c]
%
\newenvironment{shadequote}[2][l]%
{\authoralign{#1}
\ifblank{#2}
   {\def\shadequoteauthor{}\def\yshift{-2ex}\def\quotefill{\hfill}}
       {\def\shadequoteauthor{\par\authorfill\shadedauthorformat{#2}}\def\yshift{2ex}}
\begin{snugshade}\begin{quote}\openquote}
{\shadequoteauthor\quotefill\closequote{\yshift}\end{quote}\end{snugshade}}

%%% use shadequote environment 

\newcommand\myquotes[2]%
{
\begin{minipage}{2.15in}
     \scriptsize
   % \begingroup
    \linespread{2}
\begin{shadequote}[r]{#1}
    #2
\end{shadequote}
% \endgroup
   \end{minipage} 
 }

%-----------------------------------
\begin{document}
\newgeometry{left=1.4cm,top=0cm,right=1.4cm,bottom=1.2cm}
\lipsum[1-2]
\restoregeometry
\frontmatter
\justify
\strut 
\lipsum[1-2]
\strut    
\mainmatter            
\lipsum[1-2]
\textbf{-- i want the box  HERE -- !!!!}
\begin{wrapfigure}[7]{r}{.4\linewidth}
\myquotes{author, date}{some text}
\end{wrapfigure}
\lipsum[1-2]
\setcounter{secnumdepth}{4} % 
\part{Part 1} % 
\lipsum[1-2]
\end{document}

在输出 PDF 中,框始终位于文本后面(在我的报告中,它始终位于章节底部)。我该如何修复此问题。

答案1

为了修复wrapfigure环境,您可以将其放在里面minipage,请注意,文本换行应该在组(小页面)结束之前结束。

\noindent
\begin{minipage}{\linewidth}
\begin{wrapfigure}[7]{R}{.4\linewidth}
\myquotes{author, date}{some text}
\end{wrapfigure}
\lipsum[1-2]
\end{minipage}

代码

\documentclass[a4paper,11pt, oldfontcommands]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[english, frenchb]{babel}
\usepackage[a4paper]{geometry}
\usepackage{wrapfig}
\usepackage{ragged2e}
\usepackage{lipsum}
%%% code from http://www.ceus-now.com/block-quote-with-big-quotation-marks/
\usepackage{ifxetex,ifluatex}
\usepackage{etoolbox}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{framed}
% conditional for xetex or luatex
\newif\ifxetexorluatex
\ifxetex
 \xetexorluatextrue
\else
\ifluatex
 \xetexorluatextrue
 \else
 \xetexorluatexfalse
 \fi
\fi
%
 \ifxetexorluatex%
 \usepackage{fontspec}
  \usepackage{libertine} % or use \setmainfont to choose any font on your system
  \newfontfamily\quotefont[Ligatures=TeX]{Linux Libertine O} % selects Libertine as the quote font
\else
  \usepackage[utf8]{inputenc}
  \usepackage[T1]{fontenc}
  \usepackage{libertine} % or any other font package
  \newcommand*\quotefont{\fontfamily{LinuxLibertineT-LF}} % selects Libertine as the quote font
\fi

\newcommand*\quotesize{40} % if quote size changes, need a way to make shifts relative
% Make commands for the quotes
\newcommand*{\openquote}
   {\tikz[remember picture,overlay,xshift=-4ex,yshift=-2.5ex]
   \node (OQ) {\quotefont\fontsize{\quotesize}    {\quotesize}\selectfont``};\kern0pt}

\newcommand*{\closequote}[1]
  {\tikz[remember picture,overlay,xshift=4ex,yshift={#1}]
   \node (CQ) {\quotefont\fontsize{\quotesize}{\quotesize}\selectfont''};}

% select a colour for the shading
\colorlet{shadecolor}{Gray}

\newcommand*\shadedauthorformat{\emph} % define format for the author argument

% Now a command to allow left, right and centre alignment of the author
\newcommand*\authoralign[1]{%
  \if#1l
    \def\authorfill{}\def\quotefill{\hfill}
  \else
    \if#1r
      \def\authorfill{\hfill}\def\quotefill{}
    \else
      \if#1c
        \gdef\authorfill{\hfill}\def\quotefill{\hfill}
      \else\typeout{Invalid option}
      \fi
    \fi
  \fi}
% wrap everything in its own environment which takes one argument (author) and one optional argument
% specifying the alignment [l, r or c]
%
\newenvironment{shadequote}[2][l]%
{\authoralign{#1}
\ifblank{#2}
   {\def\shadequoteauthor{}\def\yshift{-2ex}\def\quotefill{\hfill}}
       {\def\shadequoteauthor{\par\authorfill\shadedauthorformat{#2}}\def\yshift{2ex}}
\begin{snugshade}\begin{quote}\openquote}
{\shadequoteauthor\quotefill\closequote{\yshift}\end{quote}\end{snugshade}}

%%% use shadequote environment 

\newcommand\myquotes[2]%
{
\begin{minipage}{2.15in}
     \scriptsize
   % \begingroup
    \linespread{2}
\begin{shadequote}[r]{#1}
    #2
\end{shadequote}
% \endgroup
   \end{minipage} 
 }

%-----------------------------------
\begin{document}
\newgeometry{left=1.4cm,top=0cm,right=1.4cm,bottom=1.2cm}
\lipsum[1-2]
\restoregeometry
\frontmatter
\justify
\strut 
\lipsum[1-2]
\strut    
\mainmatter            
\lipsum[1-2]
\textbf{-- i want the box  HERE -- !!!!}

\noindent
\begin{minipage}{\linewidth}
\begin{wrapfigure}[7]{R}{.4\linewidth}
\myquotes{author, date}{some text}
\end{wrapfigure}
\lipsum[1-2]
\end{minipage}
\setcounter{secnumdepth}{4} % 
\part{Part 1} % 
\lipsum[1-2]
\end{document}

相关内容