矛盾したリスト/項目を持つこのテーブルを LaTeX で作成するにはどうすればよいでしょうか?

矛盾したリスト/項目を持つこのテーブルを LaTeX で作成するにはどうすればよいでしょうか?

この 5 列の表の最初の 2 行を LaTeX で生成したいと思います。

ここに画像の説明を入力してください

ご覧のとおり、これは特別なタイプのテーブルであり、次のような内容が表示されます。

  • 内部に項目別リストがありますが、一貫性がありません。つまり、列 4 のすべての行に項目別リストがあり、列 2、3、および 5 には一部の行に項目別リストがありますが、すべての行に項目別リストがあるわけではなく、列 1 には項目別リストがまったくありません。
  • テーブルの配置が美しい
  • キャンディーアイのような外観は、booktabsパッケージが作成された理由です
  • 不快なスペースのないコンパクトなテーブルです
  • リストには四角い箇条書きがある

コード:

\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{lscape}
\begin{document}
\begin{landscape}
  \thispagestyle{empty}           % hide page number
  \begin{table}
    \centering
    \setlength{\belowcaptionskip}{\abovecaptionskip}% Correct skip for caption on top
    \caption{Wide Itemized Mixed Table}
    \label{tab:wide-item-tbl}
      \begin{tabular}{lp{2in}p{2in}p{2in}p{2in}}
        \toprule
        \textbf{BSL} & \textbf{Agents} & \textbf{Practices} & \textbf{Primary barriers} & \textbf{Secondary barriers} \\
        \midrule
        1 & Not known to consistently cause diseases in healthy adults & standard microbiological practices & no primary barriers required, PPE & bench and sink required \\
        2 & - Agents associated with human diseases  - Routes of transmission include per-cutaneous injury, ingestion, mucous membrane exposure & BSL-1 practice plus: - limited access - Biohazard warning signs - ``Sharps'' precautions - Biosafety manual defining any needed waste decontamination or medical surveillance polices & Primary barriers: - BSCs or other physical containment devices used for all manipulations of agents that cause splashes or aerosols of infectious materials - PPE: Laboratory coats, gloves, face and eye protection, as needed & BSL-1 plus: - Autoclave available\\
        \bottomrule
      \end{tabular}%
  \end{table}
\end{landscape}
\end{document}

私が見つけた一番近い答えはここただし、残念ながらこの回答では、すべての行に明細リストがあり、一部の行には明細リストがないことを前提としています。そのため、この投稿を重複としてラベル付けする前に、この点にご注意ください。

答え1

答えは、リストをミニページまたは parbox 内に配置することですが、これはあまり楽しいことではありません。 キーと コマンドを使用する別の解決策を次に示します。リストenumitemのみを含むセルがある場合に使用し、リストの前のテキストを含むキーをクリアします。行は正しく配置されます。beforeafter\tablistcommandtabitemizebefore

\documentclass[landscape]{scrartcl}
\usepackage{booktabs,array,enumitem,ragged2e}

\newcommand{\tablistcommand}{%
  \leavevmode\par\vspace{-\baselineskip}%
}

\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{%
  leftmargin = *               ,
  label      = \textbullet     ,
  nosep                        ,
  before     = \tablistcommand ,
  after      = \tablistcommand
}

\begin{document}
\thispagestyle{empty}
\begin{table}
  \centering
  \caption{Wide Itemized Mixed Table}
  \label{tab:wide-item-tbl}
  \begin{tabular}{@{}l*{4}{>{\RaggedRight}p{2in}}@{}}
    \toprule
    \textbf{BSL} & \textbf{Agents} & \textbf{Practices}
    & \textbf{Primary barriers} & \textbf{Secondary barriers} \\
    \midrule
    1 & Not known to consistently cause diseases in healthy adults
      & standard microbiological practices
      & \begin{tabitemize}
        \item no primary barriers required,
        \item  PPE
        \end{tabitemize}
      & bench and sink required \tabularnewline
    2 & \begin{tabitemize}
        \item Agents associated with human diseases
        \item Routes of transmission include per-cutaneous injury,
          ingestion, mucous membrane exposure
        \end{tabitemize}
      & BSL-1 practice plus:
        \begin{tabitemize}[before=]
        \item limited access
        \item Biohazard warning signs
        \item ``Sharps'' precautions
        \item Biosafety manual defining any needed waste
          decontamination or medical surveillance polices
        \end{tabitemize}
      & Primary barriers:
        \begin{tabitemize}[before=]
        \item BSCs or other physical containment devices used for all
          manipulations of agents that cause splashes or aerosols of
          infectious materials
        \item PPE: Laboratory coats, gloves, face and eye protection,
          as needed
        \end{tabitemize}
      & BSL-1 plus:
        \begin{tabitemize}[before=]
        \item Autoclave available
        \end{tabitemize}\tabularnewline
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

ここに画像の説明を入力してください


編集

使用例によって異なりますが、ドキュメント内にこのような表を作成するとよいでしょう。表が非常に長い場合は、回転させた方が合理的です。

\documentclass[a4paper]{article}
\usepackage{%
  booktabs,tabularx,enumitem,ragged2e,%
  caption,lipsum,showframe,geometry}

\captionsetup[table]{%
  format        = plain        ,
  font          = footnotesize ,
  labelfont     = bf           , 
  justification = centerlast   , 
  labelsep      = period       ,
  position      = top          ,
  aboveskip     = 5pt          ,
  belowskip     = 0pt
}

\newcommand{\tablistcommand}{%
  \leavevmode\par\vspace{-\baselineskip}%
}

\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{%
  leftmargin = *               ,
  label      = \textbullet     ,
  nosep                        ,
  before     = \tablistcommand ,
  after      = \tablistcommand
}

\begin{document}
\lipsum[1]

\begin{table}[!h]
  \caption{Wide Itemized Mixed Table}
  \label{tab:wide-item-tbl}
  \footnotesize
  \begin{tabularx}{\linewidth}{@{}l*{4}{>{\RaggedRight}X}@{}}
    \toprule
    \scriptsize BSL & \scriptsize Agents & \scriptsize Practices
    & \scriptsize Primary barriers & \scriptsize Secondary barriers \\
    \midrule
    1 & Not known to consistently cause diseases in healthy adults
      & standard microbiological practices
      & \begin{tabitemize}
        \item no primary barriers required,
        \item  PPE
        \end{tabitemize}
      & bench and sink required \tabularnewline\addlinespace
    2 & \begin{tabitemize}
        \item Agents associated with human diseases
        \item Routes of transmission include per-cutaneous injury,
          ingestion, mucous membrane exposure
        \end{tabitemize}
      & BSL-1 practice plus:
        \begin{tabitemize}[before=]
        \item limited access
        \item Biohazard warning signs
        \item ``Sharps'' precautions
        \item Biosafety manual defining any needed waste
          decontamination or medical surveillance polices
        \end{tabitemize}
      & Primary barriers:
        \begin{tabitemize}[before=]
        \item BSCs or other physical containment devices used for all
          manipulations of agents that cause splashes or aerosols of
          infectious materials
        \item PPE: Laboratory coats, gloves, face and eye protection,
          as needed
        \end{tabitemize}
      & BSL-1 plus:
        \begin{tabitemize}[before=]
        \item Autoclave available
        \end{tabitemize}\tabularnewline
    \bottomrule
  \end{tabularx}
\end{table}

\lipsum[1]
\end{document}

ここに画像の説明を入力してください

答え2

こちらは列挙項目バージョン:

ここに画像の説明を入力してください

tableitems環境のバリアントを定義しitemize、それをテーブル内で使用しました。\vspaceヘッダーのないリストに使用する扱いにくいハックに注意してください。これがないと、リストに関する空の行が存在します。

コード

    \documentclass{scrartcl}
    \usepackage{graphicx}
    \usepackage{booktabs}
    \usepackage{enumitem}
    \usepackage{lscape}
    \newlist{tableitems}{itemize}{1}
    \usepackage{mathabx}% for \sqbullet
    \setlist[tableitems]{nosep,
                         topsep=0pt,
                         partopsep=0pt,
                         leftmargin=1em,
                         label=$\sqbullet$
    }
    \begin{document}
    \begin{landscape}
      \thispagestyle{empty}           % hide page number
      \begin{table}
        \centering
        \setlength{\belowcaptionskip}{\abovecaptionskip}% Correct skip for caption on top
        \caption{Wide Itemized Mixed Table}
        \label{tab:wide-item-tbl}
          \begin{tabular}{lp{2in}p{2in}p{2in}p{2in}}
            \toprule
            \textbf{BSL} & \textbf{Agents} & \textbf{Practices} & \textbf{Primary barriers} & \textbf{Secondary barriers} \\
            \midrule
            1 & Not known to consistently cause diseases in healthy adults
              & standard microbiological practices
              &\vspace{-1em}
              \begin{tableitems}
                 \item No primary barriers required
                 \item PPE
              \end{tableitems}
              & bench and sink required
            \\\midrule
            2 & \vspace{-1ex}
            \begin{tableitems}
             \item  Agents associated with human diseases
             \item Routes of transmission include per-cutaneous injury,
                    ingestion, mucous membrane exposure
            \end{tableitems}
            & BSL-1 practice plus:
            \begin{tableitems}
               \item limited access
               \item Biohazard warning signs
               \item ``Sharps'' precautions
               \item Biosafety manual defining any needed waste
               decontamination or medical surveillance polices
            \end{tableitems}
             & Primary barriers:
            \begin{tableitems}
               \item BSCs or other physical containment devices used for all
                   manipulations of agents that cause splashes or aerosols of
                   infectious materials
               \item PPE: Laboratory coats, gloves, face and eye protection, as needed
            \end{tableitems}
             & BSL-1 plus:
            \begin{tableitems}
               \item Autoclave available
            \end{tableitems}
            \\
            \bottomrule
          \end{tabular}%
      \end{table}
    \end{landscape}
    \end{document}

答え3

完璧ではありませんが、役に立つかどうか確認してください。

\documentclass{scrartcl}
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{booktabs,makecell,tabularx}
\renewcommand\theadfont{\bfseries\sffamily}
\newcommand{\textblacksquare}{\rule[.2ex]{0.8ex}{0.8ex}}
    \usepackage{paralist}
    \usepackage{ragged2e}
    \usepackage[margin=1in,showframe]{geometry}
    \usepackage{rotating}

\begin{document}
    \thispagestyle{empty}           % hide page number
\begin{sidewaystable}
    \centering
    \small\sffamily
    \caption{Wide Itemized Mixed Table}
    \label{tab:wide-item-tbl}
  \begin{tabularx}{\textheight}{c*{4}{>{\RaggedRight\arraybackslash}X}}
    \toprule
\thead{BSL} 
    &   \thead{Agents} 
        &   \thead{Practices} 
            &   \thead{Primary barriers} 
                &   \thead{Secondary barriers}  \\
    \midrule
1   &   Not known to consistently cause diseases in healthy adults 
        &   standard microbiological practices
            &   \vspace{-2ex}
                    \begin{compactitem}[\textblacksquare]
                \item   No primary barriers required,
                \item   PPE
                    \end{compactitem}
                &   Laboratora bench and sink required \\
    \midrule
2   &   \vspace{-2ex}
            \begin{compactitem}[\textblacksquare]
        \item Agents associated with human diseases
        \item Routes of transmission include per-cutaneous injury, ingestion, mucous membrane exposure
            \end{compactitem}
        &   BSL-1 practice plus:
                \begin{compactitem}[\textblacksquare]
            \item   limited access
            \item   Biohazard warning signs
            \item   ``Sharps'' precautions
            \item   Biosafety manual defining any needed waste decontamination or medical surveillance polices
                \end{compactitem}
            &   Primary barriers:
                    \begin{compactitem}[\textblacksquare]
                \item   BSCs or other physical containment devices used for all manipulations of agents that cause splashes or aerosols of infectious materials
                \item   PPE: Laboratory coats, gloves, face and eye protection, as needed
                    \end{compactitem}
                &   BSL-1 plus:
                        \begin{compactitem}[\textblacksquare]
                    \item Autoclave available
                        \end{compactitem}   \\
    \bottomrule
    \end{tabularx}
\end{sidewaystable}
\end{document}

代わりに、from package をlandscape使用し、テーブル内のリストにはfrom package を使用しました。同様の結果は、 package を使用しても得られます(あまり詳しくありません)。テーブルにはpackage を使用し、フォーマットにはfrom package を使用します。sidewaystablerotatingcompactitemparalistenumitemtabularx\RaggedRightragged2e

ここに画像の説明を入力してください

補遺: 3つの答えをすべて組み合わせると、最良の解決策が得られるようです:-)。そこで、次のものを組み合わせます

  • $\sqbullet$mathabxアンドリューが回答で提案したパッケージパッケージから
  • enumitemArash Esbatiが回答の中でパッケージを使用する方法
  • tabularx私の回答で提案しているように、列見出しのテキストの配置を行いますsidewaystableRaggedRightmakecell

これにより、「共通」コードは次のようになります。

\documentclass{scrartcl}

\usepackage{booktabs,makecell,tabularx}
\renewcommand\theadfont{\bfseries\sffamily}
\usepackage{ragged2e}
\usepackage[a4paper,margin=1in,showframe]{geometry}
\usepackage{rotating}
%    
\usepackage{mathabx}% for \sqbullet
\usepackage{enumitem}% for nice list
\newcommand{\tablistcommand}{% <-- for eliminating vertical space
                             %     before and after itemize
            \leavevmode\par\vspace{-\baselineskip}
                            }
\newlist{tableitems}{itemize}{1}% <-- defined new list
\setlist[tableitems]{nosep,     % <-- new list setup
                     topsep     = 0pt               ,
                     partopsep  = 0pt               ,
                     leftmargin = *                 ,
                     label      = $\sqbullet$       ,
                     before     = \tablistcommand   ,
                     after      = \tablistcommand
                     }

    \begin{document}
      \thispagestyle{empty}
%---------------------------------------------------------------%
\begin{sidewaystable}[h]%table
    \centering
    \small\sffamily
\caption{Wide Itemized Mixed Table}
    \label{tab:wide-item-tbl}
\begin{tabularx}{\textwidth}{c*{4}{>{\RaggedRight\arraybackslash}X}}
    \toprule
\thead{BSL}
    &   \thead{Agents}
        &   \thead{Practices}
            &   \thead{Primary barriers}
                &   \thead{Secondary barriers}  \\
    \midrule
1   &   Not known to consistently cause diseases in healthy adults
        &   standard microbiological practices
            &   \begin{tableitems}
                \item   No primary barriers required,
                \item   PPE
                \end{tableitems}
                &   Laboratory bench and sink required \\
    \midrule
2   &   \begin{tableitems}
        \item Agents associated with human diseases
        \item Routes of transmission include per-cutaneous injury, ingestion, mucous membrane exposure
        \end{tableitems}
        &   BSL-1 practice plus:
            \begin{tableitems}[before=]% <-- nullifying before skip
            \item   limited access
            \item   Biohazard warning signs
            \item   ``Sharps'' precautions
            \item   Biosafety manual defining any needed waste decontamination or medical surveillance polices
            \end{tableitems}
            &   Primary barriers:
                \begin{tableitems}[before=]% <-- nullifying before skip
                \item   BSCs or other physical containment devices used for all manipulations of agents that cause splashes or aerosols of infectious materials
                \item   PPE: Laboratory coats, gloves, face and eye protection, as needed
                \end{tableitems}
                &   BSL-1 plus:
                    \begin{tableitems}[before=]% <-- nullifying before skip
                    \item Autoclave available
                    \end{tableitems}   \\
    \bottomrule
\end{tabularx}
\end{sidewaystable}%table
%---------------------------------------------------------------%
    \end{document}

これにより、表は以下のようになります。

ここに画像の説明を入力してください

関連情報