Text Formatting ⇒ hrule on same line as text
hrule on same line as text
Section 4.3 -------------------
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
hrule on same line as text
Code: Select all
\documentclass{article}
\usepackage[normalem]{ulem}
\begin{document}
Some text \sout{\hfill}
\end{document}
Re: hrule on same line as text
hrule on same line as text
Code: Select all
\documentclass{article}
\usepackage[normalem]{ulem}
\renewcommand{\ULthickness}{2pt}
\begin{document}
Some text \sout{\hfill}
\end{document}
hrule on same line as text

Code: Select all
\documentclass[12pt]{article}
\usepackage[top=23mm, bottom=20mm, left=25mm, right=25mm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{helvet}
\usepackage{setspace}
\usepackage{pbox}
\usepackage[normalem]{ulem}
\renewcommand{\ULthickness}{2pt}
\pdfpagewidth 215mm
\pdfpageheight 266mm
%--------------------------------------------------------------------
\begin{document}
\textbf{Section 1}\newline
\vspace{-2mm}
\hspace{15pt}\sout{\hfill}
\newline
\newline
\newline
\hspace*{6mm}Some text \ldots
\newline
\newline
\textbf{Section 2}
\vspace{2mm}
\hspace*{15mm}\hrule width 160mm height 2pt
\end{document}
hrule on same line as text
Code: Select all
\documentclass{article}
\begin{document}
Some text \rule[2pt]{1in}{2pt}\vspace{3mm}
Some more text
\end{document}
hrule on same line as text
Not to be rude, but nothing there counts as "my method". This thread was originally about placing the horizontal rule on the same line, centered, as the text. You are now trying to do something completely different, and I would suggest completely different methods!jaybz wrote:Sorry to reopen here but I have another problem. Using your method I get quite a bit of space between the text and the line,
For greater control over spacing, I recommend putting the text and the line in separate paragraphs rather than using \newline. The "wrong position" problem comes from not taking into account that the first line of a paragraph is indented. You can suppress this behavior using \noindent. Probably you want to do this with both the text, and the rule, or with neither. Compare, e.g., Section 1 and Section 2 in this example.
Rather than using \vspace commands, I'd just use the \rule command, and use its first optional argument which controls the vertical position of the bar. The syntax is \rule[vertical position]{width}{thickness}. I in Section 3 to show that vspace does the same thing (and works with paragraph breaks).
Code: Select all
\documentclass[12pt]{article}
\usepackage[top=23mm, bottom=20mm, left=25mm, right=25mm,papersize={215mm,266mm}]{geometry}
%--------------------------------------------------------------------
\begin{document}
\noindent\textbf{Section 1}
\noindent\rule[1ex]{\textwidth}{2pt}
\bigskip
Some text
\bigskip
\textbf{Section 2}
\rule[1ex]{\textwidth}{2pt}
\bigskip
Some more text
\bigskip
\textbf{Section 3}
\vspace*{-15ex}\rule{\textwidth}{2pt}
\end{document}
Something like this?
Code: Select all
\documentclass[12pt]{article}
\usepackage[top=23mm, bottom=20mm, left=25mm, right=25mm,papersize={215mm,266mm}]{geometry}
%--------------------------------------------------------------------
\usepackage[calcwidth]{titlesec}
\titleformat{\section}% sectioning command formatted
{\bfseries}% font commands applied to whole
{Section~\thesection.}% label
{0.5em}% separation between label and title
{}% commands before section title
[{\titlerule[2pt]}]% commands after
\begin{document}
\section{A section}
Some text
\section{}
Some more
\end{document}