例のリストを作成中に問題が発生しました

例のリストを作成中に問題が発生しました

パッケージ「float」を使用して、図のリストに似た例のリストを作成しましたが、例のリストのセクションは正しく表示されています。ただし、例のセクションで 2 つの問題が発生しています。

  1. 例の下にキャプションを表示したくありません。
  2. 例のセクションの出力では、例が各ページの中央に表示されます。(つまり、1 つのページに表示される例は 1 つだけで、それもページの中央に表示されます)

\begin{document} の前に含まれるパッケージと float 定義:

\documentclass[12 pt, a4paper]{book}
\usepackage{multicol}
\usepackage{geometry}
\geometry{
           a4paper,
           total={170 mm,257 mm},
           left=20 mm,
           top=20 mm,
          }
\usepackage{amsmath,bm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{soul}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{arydshln}
\usepackage{calc}
\usepackage{float}

\setlength{\parindent}{2em}

\newcommand{\wt}[2]{\underset{\substack{\textstyle\uparrow\\\hidewidth\mathstrut#2\hidewidth}}{#1}}
\definecolor{mygray}{gray}{0.6}

\floatstyle{plain}
\newfloat{example}{tbp}{loc}[chapter]
\floatname{example}{Example}

例のセクションのコード スニペット:

%% xxx---Example-1.1 Begins
\begin{example}
$\Longrightarrow$ \hspace{0.2 cm}\textbf{Example-1.1 :} \hspace{0.5 cm} \textit{Convert \hspace{0.1 cm}$(23.71)_{10}$ \hspace{0.05 cm}to its binary equivalent.}\\

\textbf{Solution :} \\

\indent \textbf{Step 1 :} \hspace{0.2 cm} Separate the integer and the fractional part. \\[0.1 cm]
\indent\indent\indent\indent Integer part: 23 \\[0.1 cm]
\indent\indent\indent\indent Fractional part: 0.71

\indent \textbf{Step 2 :} \hspace{0.2 cm} Find the binary equivalent of the integer part.
    \[\setlength\extrarowheight{2pt}
    \left.
    \hspace{-2 cm}      
    \begin{array}{c|c|c}
        \textbf{Radix} & \textbf{Integer} & \textbf{Remainder}\\
        \hline
         2 & 23 & 1\\
        \hline
         2 & 11 & 1\\
        \hline
         2 & 5 & 1\\
        \hline
         2 & 2 & 0\\
        \hline
         2 & 1 & 1\\
        \hline
           & 0 &  \\
    \end{array}
    \hspace{1 cm} \right\uparrow^{\textbf{LSB}}_{\textbf{MSB}} \\
    \]
                    
\indent \textbf{Step 3 :} \hspace{0.2 cm} Find the binary equivalent of the fractional part.
    \[
    \left.
    \begin{array}{ccccc|c}
        \textbf{Fraction} & & \textbf{Radix} & & \textbf{Product} \hspace{0.1 cm} & \hspace{0.1 cm}\textbf{Integer}\\
        0.71 & \times & 2 & = & 1.42 & 1\\
        0.42 & \times & 2 & = & 0.84 & 0\\
        0.84 & \times & 2 & = & 1.68 & 1\\
        0.68 & \times & 2 & = & 1.36 & 1\\
        0.36 & \times & 2 & = & 0.72 & 0\\
    \end{array}
    \hspace{1 cm} \right\downarrow^{\textbf{LSB}}_{\textbf{MSB}} \\
    \]
\begin{flushright}
    \underline{Ans}. $\Rightarrow$ \fboxrule=1pt \fcolorbox{black}{mygray}{Binary Equivalent of $(23.71)_{10}$ = $(10111.10110)_{2}$} \\[0.5 cm]
\end{flushright}
\caption[Decimal to Binary Conversion]{}
\label{example}
\end{example}
%% Example-1.1 Ends---xxx

例のリストのコードを挿入する前の例のセクションの出力:

望ましい出力

例のリストのコードを挿入した後の例のセクションの出力:

得られた出力

誰かこれを手伝ってくれませんか? また、私の要件を満たす float パッケージ以外の例のリストを実装するより良い方法があれば教えてください。 ぜひ教えてください!!!

答え1

MWE をもう少し小さくしました。

注: キャプションのタイトルは中括弧で囲む必要はありませんが、aux ファイルを見るとそれがデフォルトになっています。

\documentclass{book}
\usepackage{float}

\floatstyle{plain}
\newfloat{example}{tbp}{loc}[chapter]
\floatname{example}{Example}

\begin{document}
\listof{example}{List of Examples}

\begin{example}
\caption{normal caption}
First example
\end{example}

\begin{example}
\refstepcounter{example}%
\addcontentsline{loc}{example}{\string\numberline{\theexample}{Invisible caption}}%
Second example.
\end{example}

\end{document}

関連情報