5

I have following code. I need to print the \hline fainter than normal so that it does not interfere with writting (if dotted, better). Kindly help

\section*{\textrecipe}
\renewcommand\baselinestretch{3.5}\selectfont
\begin{table}[H]
\centering
\begin{tabular}{p{0.5cm}|p{2cm}|p{2cm}|p{3cm}|p{2cm}|p{3cm}}
\toprule
Sr & Drug & Dose & Frequency & Duration & Remark \\ \midrule
 1  &      &      &           &          &        \\ \hline
 2  &      &      &           &          &        \\ \hline
 3  &      &      &           &          &        \\ \hline
 4  &      &      &           &          &        \\  \hline 
 5  &      &      &           &          &        \\ \hline 
 6  &      &      &           &          &        \\ \hline 
 7  &      &      &           &          &        \\   \bottomrule
\end{tabular}
\end{table}
\renewcommand\baselinestretch{1.5}\selectfont
  • 1
    Best would be to set the width to 0pt. Shortcut: Remove all \hlines . – Johannes_B Feb 18 '17 at 11:04
  • Out of interest, why no minimal working example? Why using a float without letting it float? – Johannes_B Feb 18 '17 at 11:05
  • You can add some vertical padding around \hlines with the cellspace or makecell packages. – Bernard Feb 18 '17 at 11:07
  • What is the difference between toprule and hline?: Lines produced with \hline have a default width controlled by \arrayrulewidth which is set (by the standard classes) to 0.4pt. If you want to change the thickness, you need to set a different value for \arrayrulewidth. Doesn't that answer your question? And the linked earler question? – Johannes_B Feb 18 '17 at 11:09
  • 1
    I understand this is a table to be hand-filled, so the need of guide-line.: tex.stackexchange.com/questions/10243/table-border-options – Rmano Feb 18 '17 at 11:10
4

If removing the \hlines all together and using booktabs is not sufficient, a dotted lines version using the arydshln package may help:

\documentclass{article}
\usepackage{arydshln}

\setlength{\dashlinedash}{.4pt}
\setlength{\dashlinegap}{.8pt}

\begin{document}
\section*{textrecipe}
\renewcommand\baselinestretch{3}
\begin{table}[htb]
\centering
\begin{tabular}{p{0.5cm}:p{2cm}:p{2cm}:p{3cm}:p{2cm}:p{3cm}}
\hdashline
Sr  & Drug & Dose & Frequency & Duration & Remark \\ \hdashline
 1  &      &      &           &          &        \\ \hdashline
 2  &      &      &           &          &        \\ \hdashline
 3  &      &      &           &          &        \\ \hdashline
 4  &      &      &           &          &        \\ \hdashline 
 5  &      &      &           &          &        \\ \hdashline 
 6  &      &      &           &          &        \\ \hdashline 
 7  &      &      &           &          &        \\ \hdashline
\end{tabular}
\end{table}
\renewcommand\baselinestretch{1.5}
\end{document}

enter image description here

1

I can propose this, using grey lines rather than dashed lines. The lines won't inerfere with the contents,as I use cellspace to obtain some padding between rows. I also use booktabs for it is easy to have variable thickness lines, and it accepts colouring lines.

The cellspace package allows to define a minimal vertical spacing at the top and at the bottom of cells in columns with specifiers prefixed with the letter S (or C if you load siunitx). Paragraph-type specifiers have to be enclosed within {}. It works fine in most cases.

\documentclass{article}
\usepackage[svgnames, table]{xcolor}
\usepackage{tabularx, booktabs, cellspace}
\setlength\cellspacetoplimit{8pt}
\setlength\cellspacebottomlimit{8pt}
\addparagraphcolumntypes{X}

\begin{document}
\section*{textrecipe}
\begin{table}[! htb]
  \centering\setlength\aboverulesep{0pt}\setlength\belowrulesep{0pt}
  \arrayrulecolor{Gainsboro}
  \begin{tabularx}{\linewidth}{!{\color{Gainsboro}\vrule width 1.5pt}Sc!{\color{Gainsboro}\vrule width 1.5pt}>{\hsize=0.84\hsize}S{X}|>{\hsize=0.84\hsize}X|>{\hsize=1.24\hsize}X| >{\hsize=0.84\hsize}X|>{\hsize=1.24\hsize}X!{\color{Gainsboro}\vrule width 1.5pt}}
    \midrule[1.5pt]
    Sr & Drug & Dose & Frequency & Duration & Remark \\ \midrule[1.5pt]
    1 & & & & & \\ \midrule
    2 & & & & & \\ \midrule
    3 & & & & & \\ \midrule
    4 & & & & & \\ \midrule
    5 & & & & & \\ \midrule
    6 & & & & & \\ \midrule
    7 & & & & & \\ \bottomrule[1.5pt]
  \end{tabularx}
\end{table}

\end{document} 

enter image description here

1

This is a tikz solution. It gives you a lot of flexibility:

\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}[
    ]
    \matrix (m) [ matrix of nodes,nodes in empty cells, 
        every node/.append style={align=left}, 
        nodes = {
            %red, 
            %draw, 
            anchor=center, % https://www.wikiloc.com/wikiloc/view.do?id=16476493
            minimum height=1cm, 
            minimum width=2cm, 
            inner sep=0pt,
        },    
        column 6/.append style={nodes={minimum width=8cm}, },
    ]
    {
        Sr  & Drug & Dose & Frequency & Duration &Remark \\ 
        1  &      &      &           &          &        \\ 
        2  &      &      &           &          &        \\ 
        3  &      &      &           &          &        \\ 
        4  &      &      &           &          &        \\ 
        5  &      &      &           &          &        \\ 
        6  &      &      &           &          &        \\ 
        7  &      &      &           &          &        \\ 
    };

    % vertical lines 
    \foreach \c in {1,...,6} 
    \draw [gray] (m-1-\c.north east) --  (m-8-\c.south east);

    % horizontal continous lines
    \draw[gray] (m-1-1.north west) -- (m-1-6.north east);
    \draw[gray] (m-1-1.south west) -- (m-1-6.south east);
    \draw[gray] (m-8-1.south west) -- (m-8-6.south east);

    % horizontal dotted lines
    \foreach \r in {2,...,7} 
    \draw [dotted, blue] (m-\r-1.south west) --  (m-\r-6.south east);


\end{tikzpicture}

\end{document}

Output...

1

You can change the setting for \arrayrulewidth.

Note you don't need to set \baselinestretch, but \arraystretch. Also table is useless in this context; just center is what you need. Since \arraystretch and \arrayrulewidth are set in a group, their value will be restored at the end of center.

\documentclass{article}
\usepackage{textcomp}

\begin{document}

\section*{\textrecipe}
\begin{center}
\renewcommand\arraystretch{3.5}
\setlength\arrayrulewidth{0.1pt}

\begin{tabular}{p{0.5cm}|p{2cm}|p{2cm}|p{3cm}|p{2cm}|p{3cm}}
\hline
Sr  & Drug & Dose & Frequency & Duration & Remark \\ \hline
 1  &      &      &           &          &        \\ \hline
 2  &      &      &           &          &        \\ \hline
 3  &      &      &           &          &        \\ \hline
 4  &      &      &           &          &        \\ \hline
 5  &      &      &           &          &        \\ \hline
 6  &      &      &           &          &        \\ \hline
 7  &      &      &           &          &        \\ \hline
\end{tabular}
\end{center}

\end{document}

The picture is partial; showing the whole picture it would show artifacts due to screen resolution.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.