如何在图形底部和文本左侧显示标题

如何在图形底部和文本左侧显示标题

我在将标题放在图片底部和正文左侧时遇到了问题。请参阅附件中的图片文件。我使用的代码:

\documentclass[a4paper,10pt,twoside]{book}

\usepackage[draft]{graphicx}
\usepackage{epstopdf}

\usepackage{lipsum}

\usepackage[font=small,font=sf,labelfont=bf,labelsep=period,
justification=raggedright,singlelinecheck=false,width=2.5cm]{caption}
\DeclareCaptionLabelFormat{myformat}{\rule{1.6cm}{1pt}\\ #1 \textbf{#2}}
\captionsetup{labelformat=myformat}
\usepackage{floatrow}

\usepackage[layoutheight=232mm,layoutwidth=187mm,
    layoutvoffset= 32mm,layouthoffset= 11mm,
    showframe=true, 
%   showcrop=true
    ]{geometry}

\setlength{\oddsidemargin}{21mm}
\setlength{\evensidemargin}{16mm}
\setlength{\textheight}{196mm}
\setlength{\textwidth}{150mm}
\setlength{\headsep}{6mm}
\setlength{\headheight}{5mm}
\setlength{\topmargin}{10mm}
\setlength{\marginparsep}{0mm}
\setlength{\topmargin}{10mm}

\setlength{\leftskip}{3cm}

\begin{document}

\chapter{Introduction}
\lipsum[1]

\section{Caption location}
\lipsum[1]

\begin{figure}[!ht]
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={left,bottom}}}]{figure}[0.8\textwidth]
{\caption{Caption beside left, bottom of Small-Figure }\label{fig:01_400}}
{\includegraphics[width=10cm]{fg01_00400.eps}}
\end{figure}

\lipsum[1]

\begin{figure}[!ht]
\RawFloats
\begin{center}
{\includegraphics[width=13cm]{fg01_00500.eps}}
\end{center}\vspace{-0.8cm}
\begin{minipage}[t]{0.1\linewidth}
    \caption{Caption left, bottom of Wide-Figure}
\end{minipage}
\end{figure}

\lipsum[1]
\end{document}

正文上移

答案1

您可以使用 实现该布局floatrow。下面的代码大部分取自frsample05.tex。这个想法是在单列布局中floatrow使用环境并自定义。重要的部分是在 中设置标题。figure*widefigure\DeclareCaptionFormat{marginpars}

\documentclass{book}

\usepackage{lipsum,ragged2e}

\usepackage{geometry}
\geometry{a4paper,includemp}

\usepackage{floatrow}

\floatsetup[figure]{%
  style        = Boxed                        ,
  heightadjust = all                          ,
  frameset     = {\fboxrule=1pt\fboxsep=12pt} ,
  captionskip  = 7pt ,
}

\floatsetup[widefigure]{%
  margins           = hangoutside     ,
  capbesideposition = bottom          ,
  capbesidewidth    = \marginparwidth ,
  facing            = yes             ,
  floatwidth        = \textwidth
}

\usepackage{caption}

\DeclareCaptionFormat{marginpars}{%
  \vbox to 0pt{%
    \RaggedRight\FBifcaptop\vss\relax
    \floatfacing{%
      \addtolength\leftskip{\dimexpr \textwidth+\marginparsep\relax}%
    }{%
      \addtolength\rightskip{\dimexpr \textwidth+\marginparsep\relax}%
    }%
    #1#2\par#3%
    \FBifcaptop\relax\vss
  }%
}

\DeclareCaptionLabelFormat{myformat}{\rule{1.6cm}{1pt}\\ #1 #2}

\captionsetup{%
  font            = small  ,
  labelfont       = bf     ,
  font            = sf     ,
  labelsep        = period ,
  singlelinecheck = no}

\captionsetup[widefigure]{
  format      = marginpars ,
  labelformat = myformat
}

\def\text{{\mdseries And more text and some more text and a bit more
    text and a little more text and a little peace of text to fill
    space}}

\pagestyle{plain}

\begin{document}

\chapter{Some Chapter}

\section{Some Section}

\lipsum[1]

\begingroup
\floatsetup[widefigure]{capposition=top}
\begin{figure*}[b]
  \ffigbox
    {\lipsum[2]}
    {\caption{\texttt{widefigure} with \texttt{[b]} placement
      option.: \text }}
\end{figure*}
\endgroup

\lipsum[1]

\begin{figure*}[t]
  \ffigbox
    {\lipsum[2]}
    {\caption{\texttt{widefigure} with \texttt{[t]} placement
      option. \text}}
\end{figure*}

\lipsum[1]

\thisfloatsetup{capposition=top}
\begin{figure*}[b]
  \ffigbox
    {\rule{6cm}{3cm}}
    {\caption{\texttt{widefigure} with \texttt{[b]} placement
        option. \text}}
\end{figure*}

\lipsum[1-3]

\end{document}

在此处输入图片描述

相关内容