由 cfr 编辑

由 cfr 编辑

我有一个问题。我正在使用 LaTeX 创建 MSDS 表(实际上是一个创建 LaTeX 代码的 Web 应用程序)。

该表的基本设置是这样的,对于每个部分(共有 16 个部分),mdframed 环境(名为 boxtype1,由互联网提供)包含各种长表和“部分*”。

我提供了正在发生的事情的图表,以及其中一个部分的 LaTeX 代码示例...我知道这不是我能处理的最简单的代码,但它是正在发生的事情的一个清晰例子。

奇怪且令人恼火的分页符

%%% Document info
\documentclass[11pt]{report}
\usepackage{geometry}
\geometry{
 a4paper,
 total={210mm,297mm},
 left=20mm,
 right=20mm,
 top=30mm,
 bottom=20mm}
\usepackage{fancyhdr}
\usepackage[parfill]{parskip}       % Activate to begin paragraphs with an empty line rather than an indent

\textheight=225mm       %
\headsep=25mm         %
%

%%% Math/Fonts/Language setup -- unicode rules
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage[version=3]{mhchem} 

% Language stuff
\usepackage[icelandic]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

% Image stuff and output handling
\usepackage{pstricks}
\usepackage{color}
\definecolor{blue}{HTML}{0047ab}
\usepackage{epstopdf}

% Tikz and mdframed for section frames, as well as mdframed
\usepackage[framemethod=tikz]{mdframed}
\mdfsetup{font=\small}
\usepackage{longtable}

% Headers and footers
\usepackage{fancyhdr}

\pagestyle{fancy} % enable fancy page style
\renewcommand{\footrulewidth}{0.5pt}

\fancyhf{} % clear header and footer

\fancyhead[L]{ \textbf{{\huge Öryggisblað (MSDS)}\\ \vspace{2mm}
Samkvæmt reglugerð: 750/2008 (REACH) \vspace{2mm}}}

\fancyhead[R]{ \textbf{{Stofnað: 21.05.15}\\ \vspace{2mm}
Síðast breytt: 21.08.15  \vspace{2mm}}}

\fancyfoot[R]{{Síða\ \thepage\ af\ \pageref{LastPage}}}

% Paragraph settings and fontfamily
\setlength{\parskip}{1em}
\renewcommand{\baselinestretch}{1.0}
\renewcommand*{\familydefault}{\sfdefault}


\def\arraystretch{1.5}
\newenvironment{boxtype1}[1]
  {%
  \begin{mdframed}[
    linewidth=.5,
    everyline=true,
    backgroundcolor=gray!2,
    linecolor=black,
    middlelinewidth=0.5pt,
    font=\sffamily\small,
    splittopskip=30pt,
    splitbottomskip=20pt,
    skipabove = 25pt,
    innertopmargin = 30pt,
    innerbottommargin = 20pt,
     singleextra={
      \node[
        overlay,
        fill=white,
        anchor=west,
        font=\sffamily\large,
        inner xsep=10pt
      ] at ([xshift=10pt]O|-P) {\textbf{\color{blue} #1}};
      },
      firstextra={
      \node[
        overlay,
        fill=white,
        anchor=west,
        font=\sffamily\large,
        inner xsep=10pt
      ] at ([xshift=10pt]O|-P) {\textbf{\color{blue} #1}};
      },
    secondextra={
      \node[
        overlay,
        fill=white,
        anchor=west,
        font=\sffamily\large,
        inner xsep=10pt
      ] at ([xshift=10pt]O|-P) {\textbf{\color{blue} #1 framhald}};
      },
    middleextra={
      \node[
        overlay,
        fill=white,
        anchor=west,
        font=\sffamily\large,
        inner xsep=10pt
      ] at ([xshift=10pt]O|-P) {\textbf{\color{blue} #1 framhald}};
      }
  ]
  }
  {\end{mdframed}}


\begin{document}

\begin{boxtype1}{12. Vistfræðilegar upplýsingar}

    \textbf{\color{blue}12.1. Eiturhrif}

    \begin{longtable}{p{0.28\linewidth}p{0.65\linewidth}}
         \textbf{\color{black}Aðrar vistfræðilegar uppl.:}  &  Eitrað vatnalífverum, getur valdið neikvæðum langtíma áhrifum í vatnaumhverfi. Forðist losun út í umhverfið.\\
    \end{longtable}

    \begin{longtable}{p{0.25\linewidth}|p{0.12\linewidth}p{0.12\linewidth}p{0.12\linewidth}p{0.12\linewidth}p{0.12\linewidth}}
        \caption*{\textbf{Tafla 12.1 - Þekkt eitrunarmörk innihaldsefna}}\\

        \textbf{Efni} & \textbf{Teg. gildis} & \textbf{Gildi} & \textbf{Tími} & \textbf{Tegund} & \textbf{Undirtegund}\\
        \hline
        Kúmen vetnisperoxíð (80-15-9) & LC50 & 3,9 mg/l & 96 klst & Fiskur & Oncorhynchus mykiss\\
        Kúmen vetnisperoxíð (80-15-9) & EC50 & 18 mg/l & 48 klst & Daphnia & Daphnia magna\\
        Kúmen vetnisperoxíð (80-15-9) & EC50 & 3,1 mg/l & 72 klst & Þörungar & Pseudokirchnerella subcapitata\\
        2-Hýdroxýetýl metakrýlat (868-77-9) & LC50 & 227 mg/l & 96 klst & Fiskur & Pimephales promelas\\
        2-Hýdroxýetýl metakrýlat (868-77-9) & EC50 & 345 mg/l & 72 klst & Þörungar & Pseudokirchnerella subcapitata\\
        2-Hýdroxýetýl metakrýlat (868-77-9) & EC50 & 380 mg/l & 48 klst & Daphnia & Daphnia magna\\
        2-Hýdroxýetýl metakrýlat (868-77-9) & NOEC & 160 mg/l & 72 klst & Þörungar & Pseudokirchnerella subcapitata\\
        2-Hýdroxýetýl metakrýlat (868-77-9) & NOEC & 24,1 mg/l & 21 dagur & Daphnia & Pseudokirchnerella subcapitata\\
        Akrýlsýra (79-10-7) & LC50 & 27 mg/l & 96 klst & Fiskur & Oncorhynchus mykiss\\
        Akrýlsýra (79-10-7) & NOEC & 0,13 mg/l & 21 dagur & Daphnia & Daphnia magna\\
        Akrýlsýra (79-10-7) & EC50 & 0,13 mg/l & 72 klst & Þörungar & Desmodesmus subspicatus\\
        Maleic sýra (110-16-7) & LC50 & > 245 mg/l & 48 klst & Fiskur & Leuciscus idus\\
        Maleic sýra (110-16-7) & EC50 & 42,81 mg/l & 48 klst & Daphnia & Daphnia magna\\
        Metakrýlsýra (79-41-4) & LC50 & 100 - 180 mg/l & 96 klst & Fiskur & Danio rerio\\
        Metakrýlsýra (79-41-4) & EC50 & > 8,2 mg/l &  & Þörungar & \\
        Metakrýlsýra (79-41-4) & EC50 & > 130 mg/l & 48 klst & Daphnia & Daphnia magna\\
        Hýdroxýprópýl metakrýlat (27813-02-1) & LC50 & 493 mg/l & 48 klst & Fiskur & Leuciscus idus melanotus\\
    \end{longtable}

    \textbf{\color{blue}12.2. Þrávirkni og niðurbrjótanleiki}

    \begin{longtable}{p{0.28\linewidth}p{0.65\linewidth}}
        \textbf{\color{black}Hegðan í umhverfinu:}  &  Engar upplýsingar tiltækar.\\
    \end{longtable}

    \begin{longtable}{p{0.25\linewidth}|p{0.19999999999999998\linewidth}p{0.19999999999999998\linewidth}p{0.19999999999999998\linewidth}}
        \caption*{\textbf{Upplýsingar um niðurbrjótanleika innihaldsefna}}\\

        \textbf{Heiti} & \textbf{Aðferð} & \textbf{Niðurstaða} & \textbf{Niðurbrjótanleiki}\\
        \hline
        Kúmen vetnisperoxíð (80-15-9) & OECD 301 B & 0 \% & Enginn\\
        2-Hýdroxýetýl metakrýlat (868-77-9) & OECD 301 C & 92 - 100 \% & Mikill\\
        Akrýlsýra (79-10-7) & OECD 301 D & 81 \% & Mikill\\
        Maleic sýra (110-16-7) & OECD 301 B & 97,08 \% & Mikill\\
        Metakrýlsýra (79-41-4) & OECD 301 D & 86 \% & Mikill\\
        Hýdroxýprópýl metakrýlat (27813-02-1) & OECD 301 E & 94,2 \% & Mikill\\
    \end{longtable}

    \textbf{\color{blue}12.3. Uppsöfnun í lífverum / 12.4. Hreyfanleiki í jarðvegi}\vspace{-2mm}

    \begin{longtable}{p{0.28\linewidth}p{0.65\linewidth}}
        \textbf{\color{black}Hreyfanleiki í jarðvegi:}  &  Enginn, eftir storknun.\\
    \end{longtable}

    \begin{longtable}{p{0.25\linewidth}|p{0.12\linewidth}p{0.12\linewidth}p{0.12\linewidth}p{0.12\linewidth}p{0.12\linewidth}}
        \caption*{\textbf{BCF og Log K$_{ow}$ stuðlar}}\\

        \textbf{Efni} & \textbf{Log K$_{ow}$} & \textbf{BCF} & \textbf{Hitastig} & \textbf{Aðferð} & \textbf{Tegund}\\
        \hline
        Kúmen vetnisperoxíð (80-15-9) &  & 9,1 &  & OECD 305 & Reiknað gildi\\
        Kúmen vetnisperoxíð (80-15-9) & 2,16 &  &  &  & \\
        Akrýlsýra (79-10-7) &  & 3,16 &  &  & \\
        Akrýlsýra (79-10-7) & 0,46 &  & 25 $^\circ$C & OECD 107 & \\
        Maleic sýra (110-16-7) & -1,3 &  & 20 $^\circ$C & OECD 107 & \\
        Metakrýlsýra (79-41-4) & 0,93 &  &  &  & \\
        Hýdroxýprópýl metakrýlat (27813-02-1) & 0,97 &  &  &  & \\
    \end{longtable}

    \textbf{\color{blue}12.5. Niðurstöður úr mati á PBT- og vPvB-eiginleikum}\vspace{-2mm}

    \begin{longtable}{p{0.28\linewidth}p{0.65\linewidth}}
        \multicolumn{2}{p{0.93\linewidth}}{Ekkert innihaldsefna þessarar blöndu fellur undir viðmið PBT eða vPvB. Efnablandan flokkast því ekki sem SVHC (Substances of Very High Concern).}\\
    \end{longtable}\vspace{-5mm}

    \textbf{\color{blue}12.6. Önnur skaðleg áhrif}\vspace{-2mm}

    \begin{longtable}{p{0.28\linewidth}p{0.65\linewidth}}
         \multicolumn{2}{p{0.93\linewidth}}{Engin gögn tiltæk.}\\
    \end{longtable}\vspace{-5mm}

\end{boxtype1}


\label{LastPage}

\end{document}

是的...我知道代码看起来不太好,而且周围有一些奇怪的精确数字。但这只是用 jQuery 解析并打印出来的,所以我并没有关注代码的美观。

提前感谢 Benedikt

由 cfr 编辑

这是为了尝试制作一个稍微不那么最大化的最小示例。如果 OP 认为它准确地反映了问题,他/她可能希望将其用作进一步编辑的基础。

在此代码中,我使用不同的颜色来帮助阐明环境定义的各个部分的作用boxtype1。显然,这只是为了说明 - 除了调试目的之外,没有人会以这种方式更改颜色;)。我还使用了当前边界框,而不是语法,因为您必须知道包如何定义和O |- P,所以语法很晦涩难懂。OP

\documentclass[a4paper]{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{longtable,array}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\newenvironment{boxtype1}[1]
{%
  \begin{mdframed}[
    linewidth=.5,
    everyline=true,
    backgroundcolor=gray!2,
    linecolor=black,
    middlelinewidth=0.5pt,
    font=\sffamily\small,
    splittopskip=30pt,
    splitbottomskip=20pt,
    skipabove = 25pt,
    innertopmargin = 30pt,
    innerbottommargin = 20pt,
    firstextra={
      \node[
      overlay,
      fill=white,
      anchor=west,
      font=\sffamily\large,
      inner xsep=10pt
      ] at ([xshift=10pt]current bounding box.north west) {\textbf{\color{orange} #1}};
    },
    secondextra={
      \node[
      overlay,
      fill=white,
      anchor=west,
      font=\sffamily\large,
      inner xsep=10pt
      ] at ([xshift=10pt]current bounding box.north west) {\textbf{\color{red} #1 framhald}};
    },
    middleextra={
      \node[
      overlay,
      fill=white,
      anchor=west,
      font=\sffamily\large,
      inner xsep=10pt
      ] at ([xshift=10pt]current bounding box.north west) {\textbf{\color{green} #1 framhald}};
    }
  ]
}
{\end{mdframed}}

\begin{document}
\begin{boxtype1}{12. Vistfræðilegar upplýsingar}
  \textbf{\color{blue}12.1. Eiturhrif}\vspace{-2mm}
  \begin{longtable}{p{0.28\linewidth}p{0.65\linewidth}}
    \textbf{\color{black}Aðrar vistfræðilegar uppl.:} & Eitrað vatnalífverum, getur valdið neikvæðum langtíma áhrifum í vatnaumhverfi. Forðist losun út í umhverfið.\\
  \end{longtable}

  \begin{longtable} {>{\hskip 0pt}p{0.25\linewidth}|*{5}{>{\hskip 0pt}p{0.12\linewidth}}}
      \caption*{\textbf{Tafla 12.1 - Þekkt eitrunarmörk innihaldsefna}}\\
      \textbf{Efni}&\textbf{Teg. gildis}&\textbf{Gildi}&\textbf{Tími}&\textbf{Tegund}&\textbf{Undirtegund}\\
      \hline
      Kúmen vetnisperoxíð (80-15-9)&LC50&3,9 mg/l&96 klst&Fiskur&Oncorhynchus mykiss\\
      Kúmen vetnisperoxíð (80-15-9)&EC50&18 mg/l&48 klst&Daphnia&Daphnia magna\\
      Kúmen vetnisperoxíð (80-15-9)&EC50&3,1 mg/l&72 klst&Þörungar&Pseudokirchnerella subcapitata\\
      2-Hýdroxýetýl metakrýlat (868-77-9)&LC50&227 mg/l&96 klst&Fiskur&Pimephales promelas\\
      2-Hýdroxýetýl metakrýlat (868-77-9)&EC50&345 mg/l&72 klst&Þörungar&Pseudokirchnerella subcapitata\\
      2-Hýdroxýetýl metakrýlat (868-77-9)&EC50&380 mg/l&48 klst&Daphnia&Daphnia magna\\
      2-Hýdroxýetýl metakrýlat (868-77-9)&NOEC&160 mg/l&72 klst&Þörungar&Pseudokirchnerella subcapitata\\
      2-Hýdroxýetýl metakrýlat (868-77-9)&NOEC&24,1 mg/l&21 dagur&Daphnia&Pseudokirchnerella subcapitata\\
      Akrýlsýra (79-10-7)&LC50&27 mg/l&96 klst&Fiskur&Oncorhynchus mykiss\\
      Akrýlsýra (79-10-7)&NOEC&0,13 mg/l&21 dagur&Daphnia&Daphnia magna\\
      Akrýlsýra (79-10-7)&EC50&0,13 mg/l&72 klst&Þörungar&Desmodesmus subspicatus\\
      Maleic sýra (110-16-7)&LC50&> 245 mg/l&48 klst&Fiskur&Leuciscus idus\\
      Maleic sýra (110-16-7)&EC50&42,81 mg/l&48 klst&Daphnia&Daphnia magna\\
      Metakrýlsýra (79-41-4)&LC50&100 - 180 mg/l&96 klst&Fiskur&Danio rerio\\
      Metakrýlsýra (79-41-4)&EC50&> 8,2 mg/l&&Þörungar&\\
      Metakrýlsýra (79-41-4)&EC50&> 130 mg/l&48 klst&Daphnia&Daphnia magna\\
      Hýdroxýprópýl metakrýlat (27813-02-1)&LC50&493 mg/l&48 klst&Fiskur&Leuciscus idus melanotus\\
    \end{longtable}

\end{boxtype1}
\end{document}

更少 最大 最小

相关内容