0

I can't seem to shift an \hrule to the right so that it starts some distance after the left margin.

\documentclass[margin=1mm,varwidth]{standalone}
\begin{document}
  \hrule width5pt
  hello
\end{document}

output

wanted output (red segment represents horizontal space preceding hrule)

0

2 Answers 2

2

You can do it as follows; note that varwidth does several things that make this unusable in that context.

\moveright0.2cm\vbox{\hrule width5pt}\nointerlineskip
\noindent hello

\bye

In order to trick varwidth, you can do

\documentclass[margin=1mm,varwidth]{standalone}
\begin{document}

\vbox{\moveright0.2cm\vbox{\hrule width5pt}}\nointerlineskip
  hello

\end{document}

enter image description here

1

It's possible, but you have to use \vrule instead, and you'll need more boxes and an explicit dimen, at least as far as I can see.

Here, I'm assuming that you want your rule horizontally shifted by the width of the letter "h"; hence, I'm explicitly defining a \newbox called \hhbox, which is an \hbox containing only the letter "h". I'm then defining a dimen, \hwid, which is the width of \hhbox.

We then put together a \vbox which contains two \hboxes, one with the rule shifted to the right by the width of \hwid, and one with the word "hello". I've used explicit heights for the \vboxes to keep everything close together; making it more flexible is left as an exercise for the reader.

\documentclass[varwidth]{standalone}
\begin{document}
    \newdimen\hwid
    \newbox\hhbox\setbox\hhbox\hbox{h}
    \hwid=\wd\hhbox
    \vbox to10pt{%
        \vbox to0pt{\hbox{\hskip\hwid\vrule height0.5pt width5pt depth0pt}}%
        \vbox to10pt{\hbox{hello}}%
    }%
\end{document}

As far as I can tell, this also works with less exotic document class choices, like article:

Results

Is that at least vaguely what you're looking for?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .