KOMA 스크립트: 한 가지 유형의 플로트에 대해서만 캡션 글꼴을 변경합니다.

KOMA 스크립트: 한 가지 유형의 플로트에 대해서만 캡션 글꼴을 변경합니다.

새로운 유형의 플로트를 설정했습니다. fontspec의 패키지를 사용하여 scrreprt해당 플로트 유형에 대해서만 캡션 글꼴을 어떻게 변경합니까? 지금은 ( 이전에 지정했던) \addtokomafont{caption}{\gillfont}and를 사용하고 있습니다 . 물론 이렇게 하면 모든 플로트의 캡션 글꼴이 변경됩니다. 새 환경에서만 이 작업을 수행하려면 어떻게 해야 합니까 ?\addtokomafont{captionlabel}{\gillfont}\gillfonttextbox

여기에 이미지 설명을 입력하세요

MWE:

    \documentclass{scrreprt}
    \usepackage{lmodern}
    \usepackage[T1]{fontenc}
    \usepackage[english]{babel}

    %%%---being able to use all installed fonts (must compile with LuaLaTeX!)
    \usepackage{fontspec}
    \newfontfamily\gillfont{Gill Sans MT}

    %%%---setting up Box environment as float

    \usepackage{newfloat}
    \usepackage{caption}
    \DeclareFloatingEnvironment[fileext=frm,placement={H},name=Box]{myfloat}

    \captionsetup[myfloat]{labelfont=bf}

    \usepackage[framemethod=TikZ]{mdframed}

    \newenvironment{textbox}[1]
    {\begin{myfloat}[tb]
            \begin{mdframed}[backgroundcolor=gray!10]
                \caption{#1}
                            }
                {\end{mdframed}\end{myfloat}
    }

    %%%---formatting float captions

    \usepackage{chngcntr}
    \counterwithout{myfloat}{chapter}
    \counterwithout{figure}{chapter}
    \counterwithout{table}{chapter}%%--no chapter numbers in floats ("1" instead of "1.1")


    \usepackage[singlelinecheck=false, format=plain]{caption}

    \addtokomafont{caption}{\gillfont}
    \addtokomafont{captionlabel}{\gillfont}

    \usepackage{lipsum}


    \begin{document}

    \begin{textbox}{More details}\label{box1}
    \lipsum[1]
\end{textbox}

\begin{figure}[h]
    \includegraphics[width=0.4\linewidth]{example-image-a}
    \caption{\lipsum[2]}
\end{figure}

\end{document}

답변1

newfloat패키지 와 가 없는 또 다른 제안이 있습니다 caption. 또한 package 를 mdframedpackage 로 교체하겠습니다 tcolorbox.

\documentclass{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

%%%---being able to use all installed fonts (must compile with LuaLaTeX!)
\usepackage{fontspec}
\newfontfamily\gillfont{Gill Sans MT}

\DeclareNewTOC[
  type=myfloat,
  float,% defines floating environment myfloat
  %nonfloat,% defines nonfloating environment myfloat-
  tocentryindent=1.5em,
  tocentrynumwidth=2.3em,
  name=Box,
  listname={Boxes},
  atbegin={\addtokomafont{caption}{\gillfont}\addtokomafont{captionlabel}{\gillfont}}
]{frm}

\usepackage{tcolorbox}
\newenvironment{textbox}[1]
  {\begin{myfloat}[tb]
    \begin{tcolorbox}[colback=gray!10,arc=0mm,boxrule=.4pt]
      \caption{#1}%
  }
  {\end{tcolorbox}\end{myfloat}}


%\usepackage{chngcntr}% needed for older TeX distributions
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\KOMAoptions{captions=nooneline}% can also be set as class option
\setcapindent{0pt}

\usepackage{lipsum}% only for dummy text
\begin{document}
\listofmyfloats
\listoffigures
\clearpage
\begin{textbox}{More details}\label{box1}
  \lipsum[1]
\end{textbox}

\begin{figure}[hb]
  \includegraphics[width=0.4\linewidth]{example-image-a}
  \caption{\lipsum[2]}
\end{figure}
\end{document}

결과:

여기에 이미지 설명을 입력하세요


당신도 사용하려면 위 예의 명령을 다음으로 \captionof{myfloat}{...}바꾸십시오 .\DeclareNewTOC

\DeclareNewTOC[
  type=myfloat,
  float,% defines floating environment myfloat
  %nonfloat,% defines nonfloating environment myfloat-
  tocentryindent=1.5em,
  tocentrynumwidth=2.3em,
  name=Box,
  listname={Boxes}
]{frm}
\makeatletter
\addtokomafont{caption}{\ifstr{\@captype}{myfloat}{\gillfont}{}}
\addtokomafont{captionlabel}{\ifstr{\@captype}{myfloat}{\gillfont}{}}
\makeatother

예:

\documentclass{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

%%%---being able to use all installed fonts (must compile with LuaLaTeX!)
\usepackage{fontspec}
\newfontfamily\gillfont{Gill Sans MT}

\DeclareNewTOC[
  type=myfloat,
  float,% defines floating environment myfloat
  %nonfloat,% defines nonfloating environment myfloat-
  tocentryindent=1.5em,
  tocentrynumwidth=2.3em,
  name=Box,
  listname={Boxes}
]{frm}

\makeatletter
\addtokomafont{caption}{\ifstr{\@captype}{myfloat}{\gillfont}{}}
\addtokomafont{captionlabel}{\ifstr{\@captype}{myfloat}{\gillfont}{}}
\makeatother

\usepackage{tcolorbox}
\newenvironment{textbox}[1]
  {\begin{myfloat}[tb]
    \begin{tcolorbox}[colback=gray!10,arc=0mm,boxrule=.4pt]
      \caption{#1}%
  }
  {\end{tcolorbox}\end{myfloat}}


%\usepackage{chngcntr}% needed for older TeX distributions
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\KOMAoptions{captions=nooneline}% can also be set as class option
\setcapindent{0pt}

\usepackage{lipsum}% only for dummy text
\begin{document}
\listofmyfloats
\listoffigures
\clearpage
\begin{textbox}{More details}\label{box1}
  \lipsum[1]
\end{textbox}

\begin{figure}[hb]
  \includegraphics[width=0.4\linewidth]{example-image-a}
  \caption{\lipsum[2]}
\end{figure}
\captionof{myfloat}{Test myfloat}
\captionof{figure}{Test figure}
\end{document}

관련 정보