GeneralLine

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Jchen066
Posts: 13
Joined: Tue Aug 28, 2018 12:50 am

Line

Post by Jchen066 »

Hi Guys,

Anyone can help me with the code to insert dash line in the document? and how to change space between the line and the style of the line, and the color

Thanks
Sam
Attachments
Line.PNG
Line.PNG (10.58 KiB) Viewed 10829 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Line

Post by Stefan Kottwitz »

Hi Sam,

you could use the dashrule package. For example:

Code: Select all

\documentclass{article}
\usepackage{dashrule}
\begin{document}
text

\hdashrule[0.75ex]{\textwidth}{1pt}{1ex}

text
\end{document}
Click the link above to see the manual with explanation of the options. You can use the usual color commands if you like, such as
\textcolor{red}{\hdashrule[0.75ex]{\textwidth}{1pt}{1ex}}

if you load the color or xcolor package.

Stefan
LaTeX.org admin
Jchen066
Posts: 13
Joined: Tue Aug 28, 2018 12:50 am

Line

Post by Jchen066 »

Stefan Kottwitz wrote:Hi Sam,

you could use the dashrule package. For example:

Code: Select all

\documentclass{article}
\usepackage{dashrule}
\begin{document}
text

\hdashrule[0.75ex]{\textwidth}{1pt}{1ex}

text
\end{document}
Click the link above to see the manual with explanation of the options. You can use the usual color commands if you like, such as
\textcolor{red}{\hdashrule[0.75ex]{\textwidth}{1pt}{1ex}}

if you load the color or xcolor package.

Stefan

Thanks Stefan..

This is useful.

is there a way to auto fill the dash line for the rest or entire A4 page?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Line

Post by Stefan Kottwitz »

Perhaps like this:

Code: Select all

\documentclass{article}
\usepackage{dashrule}
\usepackage{xcolor}
\newlength{\mypageheight}
\newcommand\lines[3][1pt]{%
  \setlength{\mypageheight}{#3}%
  \loop%
  \addtolength{\mypageheight}{-#2}%
  \ifdim\mypageheight>0pt%
  \textcolor{red}{\hdashrule{\textwidth}{#1}{#2}}%
  \repeat%
}
\begin{document}
\noindent text

\noindent text

\noindent\lines[1pt]{1ex}{0.68\textheight}

\end{document}
Stefan
LaTeX.org admin
Jchen066
Posts: 13
Joined: Tue Aug 28, 2018 12:50 am

Line

Post by Jchen066 »

this seems to fill a full page of lines. how do i use the macro to fulfil the line for the rest of the lines (if there is only 5 line's of space left in the current
Post Reply