如何在tabularx環境中建立虛線

如何在tabularx環境中建立虛線

我一直在研究這個問題,並遇到了兩個主要的「解決方案」:

\usepackage{arydshln}

如上所述這裡

和這個:

\usepackage{dashrule}

如中所述這另一篇文章

但是,由於我正在加載這些包:

\usepackage{array}
\usepaclage{tabularx}
\usepackage{longtable}
\usepackage{tabu}

看來我既不能使用也不能arydshln使用dashline

知道為什麼會發生這種情況嗎?我怎樣才能在我的tabularx裡面得到一條水平虛線同時-在一個table環境內?

這就是我所擁有的:

\documentclass{article}

\usepackage{multirow}
\usepackage{array}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tabu}


\begin{document}
Hello.

\begin{longtabu}{l p{0.8\linewidth}}
WHO                 &   \hspace{5mm} World Health Organization\\[1mm]
GDP                 & \hspace{5mm} Gross Domestic Product\\[1mm]
PPP                 & \hspace{5mm} Purchasing Power Parities\\[1mm]

\end{longtabu}

\begin{table}\tiny
    \caption{Muscles of the thigh}
    \newcolumntype{Y}{>{\raggedright\arraybackslash}X}
    \begin{tabularx}{\textwidth}{YYYYY}
        Muscle & Origin & Insertion& Nerve & Action \\
        \firsthline\\
            \textbf{Anterior Compartment}   & & &   &   \\[3mm]

            Quadriceps femoris                                                                                          &
            Rectus Femoris: anterior inferior iliac spine. Vastus Lateralis: greater trochanter and linea aspera of femur. Vastus Intermedius: body of femur.  Vastus Medialis: linea aspera of femur                &
            Patella and onto tibial tuberosity through patellar ligament        &
            Femoral                                                                                                                 &
            Extends knee; rectus femoris also flexes hip\\\\

            Sartorius                                                                                                               &
            Anterior superiro iliac spine                                                                       &
            Medial side of tibial tuberosity                                                                &
            Femoral                                                                                                                 &
            Flexes hip and knee; rotates thigh laterally and leg medially\\\\

            \hline\\% I want this line to be dashed
            \textbf{Medial Compartment} & & &   &   \\[3mm]

            Adductor brevis                                                                                                 &
            Pubis                                                                                                                       &
            Pectineal line and linea aspera of femur                                                &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            Adductor longus                                                                                                 &
            Pubis                                                                                                                       &
            Linea aspera of femur                                                                                       &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            \lasthline\\
    \end{tabularx}
    \label{tab:ThighMuscles2}
\end{table} 


\end{document}

現在,如果我使用\dashrulewhere the \hlineis (dashrule當然在加載包之後),我會得到一個未定義的控制序列錯誤。

如果我使用\hdashlinearydshln包的)我會收到 101 錯誤,這些錯誤將我指向文檔中的其他表,所以我猜測它與我加載的其他包不相容有關。

答案1

在此輸入影像描述

它對我有用,沒有錯誤,如果它對您不起作用,您需要製作一個顯示問題的範例。

\documentclass{article}

\usepackage{multirow}
\usepackage{array}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{arydshln}

\begin{document}
Hello.

\begin{table}\tiny
    \caption{Muscles of the thigh}
    \newcolumntype{Y}{>{\raggedright\arraybackslash}X}
    \begin{tabularx}{\textwidth}{YYYYY}
        Muscle & Origin & Insertion& Nerve & Action \\
        \firsthline\\
            \textbf{Anterior Compartment}   & & &   &   \\[3mm]

            Quadriceps femoris                                                                                          &
            Rectus Femoris: anterior inferior iliac spine. Vastus Lateralis: greater trochanter and linea aspera of femur. Vastus Intermedius: body of femur.  Vastus Medialis: linea aspera of femur                &
            Patella and onto tibial tuberosity through patellar ligament        &
            Femoral                                                                                                                 &
            Extends knee; rectus femoris also flexes hip\\\\

            Sartorius                                                                                                               &
            Anterior superiro iliac spine                                                                       &
            Medial side of tibial tuberosity                                                                &
            Femoral                                                                                                                 &
            Flexes hip and knee; rotates thigh laterally and leg medially\\\\

            \hdashline\\% I want this line to be dashed
            \textbf{Medial Compartment} & & &   &   \\[3mm]

            Adductor brevis                                                                                                 &
            Pubis                                                                                                                       &
            Pectineal line and linea aspera of femur                                                &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            Adductor longus                                                                                                 &
            Pubis                                                                                                                       &
            Linea aspera of femur                                                                                       &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            \lasthline\\
    \end{tabularx}
    \label{tab:ThighMuscles2}
\end{table} 


\end{document}

使用更新後的示例,longtabu如果您更改longtabulongtable“包tabu有一些不錯的想法”,則它可以工作,但不幸的是,它錯誤地定義了標準乳膠數組包>{..}語法(這是包的有意記錄的功能,而不是錯誤),並且具有其他不相容性,所以經常需要走“禁忌之路”,只使用該軟體包的功能或使用以下軟體包的組合:旨在同時使用時相互配合而不發生衝突。

相關內容