Utwórz proste środowisko „schematu” i „Listę schematów”

Nov 22 2020

Mam napisaną i złożoną większość pracy magisterskiej. Obecnie mam listę rycin i listę tabel.

Jednak teraz moja komisja mówi mi, że muszę mieć również listę programów. W chemii schemat to środowisko zawierające (obrazy) struktur i reakcji chemicznych.

Niestety, już zakodowałem swoje struktury chemiczne w postaci liczb. Istnieje kilka pakietów, takich jak chemstylei chemscheme, które wydają się udostępniać własne konstrukcje schematów. Jednak wolałbym ich nie używać, ponieważ niektóre z tych pakietów mają własne ustawienia domyślne dla rzeczy takich jak wzory chemiczne. (Na przykład widzę, że chemstylepakiet definiuje \ie, ale mam już własną definicję dla \iew mojej pracy). Już używam pakietów chemformulai chemmacros.

Czy jest jakiś sposób na prostsze utworzenie własnego środowiska Scheme? Jedyną potrzebną mi różnicą jest to, że programy powinny być opisane jako „Schemat” i wymienione na liście programów. Innymi słowy, jedyna różnica między liczbą a schematem dotyczy księgowości.

Oto moje MWE z kilkoma kluczowymi pakietami, których używam. Jedną z możliwych komplikacji jest to, że używam subcaptionpakietu do tworzenia podkonfiguracji. Zwykle mam tylko jeden obraz na rysunek / schemat, ale tworzę odniesienia podrzędne, używając \phantomsubcaptionz subcaptionpakietu. Ponadto używam tocloftpakietu do dostosowywania odstępów na listach rysunków i tabel, co może jeszcze bardziej skomplikować sprawę.

Na koniec byłoby miło, gdybym mógł użyć nowego środowiska "schematu" z cleverefpakietem, ponieważ \crefczęsto używam polecenia z tego pakietu, aby odwołać się do rysunków, tabel itp.

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage[subrefformat=parens]{subcaption}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
]{microtype}
\usepackage{booktabs}
\usepackage{acro}
\acsetup{
  barriers/use, barriers/reset,
  use-id-as-short,
}
\newcommand{\ie}{i.e.}
\newcommand{\eg}{e.g.}
\newcommand{\cf}{cf.}
\newcommand{\avg}[1]{\overline{#1}}
\usepackage{mdframed}
\usepackage[capitalize]{cleveref}
\usepackage{chemformula}
\setchemformula{charge-hshift=.5pt}
\usepackage{chemmacros}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{calc}
\usepackage{tabto}
\usepackage[titles]{tocloft}
\setlength{\cftfignumwidth}{2.9em}
\setlength{\cfttabnumwidth}{2.9em}

\begin{document}

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

% \phantomsection %% Remove if using hyperref
\addcontentsline{toc}{chapter}{\listtablename}
\listoftables

\chapter{First chapter}
Text in the first chapter.
Refer to \cref{fig:firstfig} using cleveref package.
Refer to \cref{tbl:firsttbl}.
Refer to \cref{fig:multi}, \cref{fig:multi:a}, and \cref{fig:multi:b}.
Refer to eventual scheme, \cref{scm:eventualscheme}.
Refer to eventual multi-part scheme, \cref{scm:eventualmultischeme}.
% Example figure
\begin{figure}[!h]
  \centering
  \includegraphics[width=0.02\textwidth]{example-image}
  \caption{Caption of figure in first chapter.}\label{fig:firstfig}
\end{figure}

% Example table 
\begin{table}[!h]
  \centering
  \begin{tabular}{ll}
    \toprule
    A & B\\
    \bottomrule
  \end{tabular}
  \caption{Caption of table in first chapter.}\label{tbl:firsttbl}
\end{table}

% MULTIPART FIGURE 
\begin{figure}[!h]
  \centering
  \begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=0.02\textwidth]{example-image}
    \phantomsubcaption\label{fig:multi:a}
  \end{subfigure}
  \begin{subfigure}{0pt}
    \phantomsubcaption\label{fig:multi:b}
  \end{subfigure}
  \caption{Caption of figure referring to parts \subref{fig:multi:a} and \subref{fig:multi:b} with subref command.}\label{fig:multi}
\end{figure}

% I NEED TO CHANGE THE FOLLOWING FIGURE TO A SCHEME (SINGLE-PART SCHEME)
\begin{figure}[!h]
  \centering
  \includegraphics[width=0.02\textwidth]{example-image-a}
  \caption{Caption of eventual scheme.}\label{scm:eventualscheme}
\end{figure}

% I NEED TO CHANGE THE FOLLOWING FIGURE TO A SCHEME (MULTI-PART SCHEME, BUT ONLY WITH ONE IMAGE)
\begin{figure}[!h]
  \centering
  \begin{subfigure}{\textwidth}
    \centering
    \includegraphics[width=0.02\textwidth]{example-image-b}
    \phantomsubcaption\label{scm:eventualmultischeme:a}
  \end{subfigure}
  \begin{subfigure}{0pt}
    \phantomsubcaption\label{scm:eventualmultischeme:a}
  \end{subfigure}
  \caption{Caption of eventual scheme referring to parts \subref{fig:multi:a} and \subref{fig:multi:b} with subref command.}\label{scm:eventualmultischeme}
\end{figure}

\chapter{Second chapter}
Text in the second chapter.
Refer to \cref{fig:secondfig}.
% Another example figure
\begin{figure}[!h]
  \centering
  \includegraphics[width=0.02\textwidth]{example-image}
  \caption{Caption of figure in second chapter.}\label{fig:secondfig}
\end{figure}
\end{document}

Odpowiedzi

3 leandriis Nov 22 2020 at 16:36

Oto jak możesz połączyć chemmacros' schememoduł z subcaptioni cleveref. Zmieniłem również styl odniesienia, aby pasował do podrysów.

Niestety \listofschemesobecnie wydaje się niekompatybilny z bookklasą (Zobacz także: odpowiedni raport o błędzie ). Dlatego użyłem reportdla następującego MWE:

  • Lista schematów:

  • Odniesienia do schematów i podschematów:

  • Podpisy programów:

\documentclass[oneside,11pt]{report}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage[subrefformat=parens]{subcaption}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
]{microtype}
\usepackage{booktabs}
\usepackage{acro}
\acsetup{
  barriers/use, barriers/reset,
  use-id-as-short,
}
\newcommand{\ie}{i.e.}
\newcommand{\eg}{e.g.}
\newcommand{\cf}{cf.}
\newcommand{\avg}[1]{\overline{#1}}
\usepackage{mdframed}

\usepackage{chemformula}
\setchemformula{charge-hshift=.5pt}
\usepackage{chemmacros}
\chemsetup{modules=scheme}

\AtEndPreamble{\DeclareCaptionSubType*{scheme}\counterwithin{scheme}{chapter}\renewcommand\thesubscheme{\thescheme\alph{subscheme}}}


\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{calc}
\usepackage{tabto}
\usepackage[titles]{tocloft}
\setlength{\cftfignumwidth}{2.9em}
\setlength{\cfttabnumwidth}{2.9em}

\usepackage{xpatch}
\makeatletter
\xapptocmd{\@chapter}{\addtocontents{los}{\protect\addvspace{10\p@}}}{}{}
\makeatother

\usepackage[capitalize]{cleveref}
\crefformat{subscheme}{\schemename~#2#1#3}


\begin{document}

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

% \phantomsection %% Remove if using hyperref
\addcontentsline{toc}{chapter}{\listtablename}
\listoftables

\addcontentsline{toc}{chapter}{\listschemename}
\listofschemes

\chapter{First chapter}
Text in the first chapter.

Refer to \cref{fig:firstfig} using cleveref package.

Refer to \cref{tbl:firsttbl}.

Refer to \cref{fig:multi}, \cref{fig:multi:a}, and \cref{fig:multi:b}.

Refer to eventual scheme, \cref{scm:eventualscheme}.

Refer to eventual multi-part scheme, \cref{scm:eventualmultischeme}, \cref{scm:eventualmultischeme:a}, and \cref{scm:eventualmultischeme:b}.


\begin{figure}[!h]
  \caption{Caption of figure in first chapter.}\label{fig:firstfig}
\end{figure}


\begin{table}[!h]
  \caption{Caption of table in first chapter.}\label{tbl:firsttbl}
\end{table}

 
\begin{figure}[!h]
  \begin{subfigure}{\textwidth}
    \phantomsubcaption\label{fig:multi:a}
  \end{subfigure}
  \begin{subfigure}{0pt}
    \phantomsubcaption\label{fig:multi:b}
  \end{subfigure}
  \caption{Caption of figure referring to parts \subref{fig:multi:a} and \subref{fig:multi:b} with subref command.}\label{fig:multi}
\end{figure}


\begin{scheme}[!h]
  \caption{Caption of scheme.}\label{scm:eventualscheme}
\end{scheme}

\begin{scheme}[!h]

  \begin{subfigure}{\textwidth}
    \phantomsubcaption\label{scm:eventualmultischeme:a}
  \end{subfigure}
  \begin{subfigure}{0pt}
    \phantomsubcaption\label{scm:eventualmultischeme:b}
  \end{subfigure}
  \caption{Caption of scheme referring to parts \subref{fig:multi:a} and \subref{fig:multi:b} with subref command.}\label{scm:eventualmultischeme}
\end{scheme}

\chapter{Second chapter}
Text in the second chapter.
Refer to \cref{fig:secondfig}.

\begin{figure}[!h]
  \caption{Caption of figure in second chapter.}\label{fig:secondfig}
\end{figure}

\begin{scheme}[!h]
  \caption{Caption of scheme.}\label{scm:eventualscheme2}
\end{scheme}

\end{document}
3 egreg Nov 22 2020 at 18:34

Załaduj newfloatpaczkę i schememoduł dla chemmacros.

Musisz tylko ustawić subschemeśrodowisko dla subcaption, które należy zrobić na początku dokumentu.

Załadowałem tocbibinddo dodania \listoffiguresi \listoftablesdo spisu treści. Twoja metoda ręczna jest nieprawidłowa: powinieneś to zrobić przynajmniej \cleardoublepagewcześniej \addcontentsline.

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage[subrefformat=parens]{subcaption}
\usepackage{newfloat}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
]{microtype}
\usepackage{booktabs}
\usepackage{acro}
\usepackage{mdframed}
\usepackage{chemformula}
\usepackage{chemmacros}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{calc}
\usepackage{tabto}
\usepackage[titles]{tocloft}
\usepackage[nottoc]{tocbibind}
\usepackage[capitalize]{cleveref} % should be last

% acro options
\acsetup{
  barriers/use, barriers/reset,
  use-id-as-short,
}
% chemmacros options
\usechemmodule{scheme}
% chemformula options
\setchemformula{charge-hshift=.5pt}
% tocloft options
\setlength{\cftfignumwidth}{2.9em}
\setlength{\cfttabnumwidth}{2.9em}
% caption options
\AtBeginDocument{\DeclareCaptionSubType*[alph]{scheme}}

% personal commands
\newcommand{\ie}{i.e.}
\newcommand{\eg}{e.g.}
\newcommand{\cf}{cf.}
\newcommand{\avg}[1]{\overline{#1}}

\begin{document}

\tableofcontents
\listoffigures
\listoftables
\listofschemes

\chapter{First chapter}

Text in the first chapter.
Refer to \cref{fig:firstfig} using cleveref package.
Refer to \cref{tbl:firsttbl}.
Refer to \cref{fig:multi}, \cref{fig:multi:a}, and \cref{fig:multi:b}.
Refer to eventual scheme, \cref{scm:eventualscheme}.
Refer to eventual multi-part scheme, \cref{scm:eventualmultischeme}.

% Example figure
\begin{figure}[!h]
  \centering
  \includegraphics[width=0.02\textwidth]{example-image}
  \caption{Caption of figure in first chapter.}\label{fig:firstfig}
\end{figure}

% Example table 
\begin{table}[!h]
  \centering
  \begin{tabular}{ll}
    \toprule
    A & B\\
    \bottomrule
  \end{tabular}
  \caption{Caption of table in first chapter.}\label{tbl:firsttbl}
\end{table}

% MULTIPART FIGURE 
\begin{figure}[!h]
  \centering
  \begin{subfigure}{0.45\textwidth}
    \centering
    \includegraphics[width=0.02\textwidth]{example-image}
    \phantomsubcaption\label{fig:multi:a}
  \end{subfigure}
  \begin{subfigure}{0.45\textwidth}
    \includegraphics[width=0.02\textwidth]{example-image}
    \phantomsubcaption\label{fig:multi:b}
  \end{subfigure}
  \caption{Caption of figure referring to parts \subref{fig:multi:a} and \subref{fig:multi:b} with subref command.}\label{fig:multi}
\end{figure}

\begin{scheme}[!h]
  \centering
  \includegraphics[width=0.02\textwidth]{example-image-a}
  \caption{Caption of eventual scheme.}\label{scm:eventualscheme}
\end{scheme}

\begin{scheme}[!h]
  \centering
  \begin{subscheme}{0.45\textwidth}
    \centering
    \includegraphics[width=0.02\textwidth]{example-image-a}
    \phantomsubcaption\label{scm:eventualmultischeme:a}
  \end{subscheme}
  \begin{subscheme}{0.45\textwidth}
    \includegraphics[width=0.02\textwidth]{example-image-b}
    \phantomsubcaption\label{scm:eventualmultischeme:b}
  \end{subscheme}
  \caption{Caption of eventual scheme referring to parts \subref{fig:multi:a} and \subref{fig:multi:b} with subref command.}\label{scm:eventualmultischeme}
\end{scheme}

\chapter{Second chapter}

Text in the second chapter.
Refer to \cref{fig:secondfig}.

% Another example figure
\begin{figure}[!h]
  \centering
  \includegraphics[width=0.02\textwidth]{example-image}
  \caption{Caption of figure in second chapter.}\label{fig:secondfig}
\end{figure}

\end{document}
2 gernot Nov 22 2020 at 02:50

Jak @leandriis zauważył w komentarzach, chemmacrospakiet najwyraźniej już robi to, co chcesz.

W przeciwnym razie wystarczy dodać linie

\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext=los,placement={!ht},name=Scheme]{myscheme}
\captionsetup[myscheme]{labelfont=bf}
\crefname{myscheme}{scheme}{schemes}

do preambuły, a następnie może użyć nowego typu zmiennoprzecinkowego, myschemepodobnego do figures. Lista schematów jest tworzona za pomocą \listofmyschemes.