Page LayoutNew command "random"

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
jhapk
Posts: 81
Joined: Tue Apr 20, 2010 9:33 pm

New command "random"

Post by jhapk »

I want to have a command called "random". I wrote something like this

Code: Select all

\documentclass{scrbook}
\usepackage{mwe}
\newcommand{\random}[1]{\vspace{0.2in}{#1}\vspace{0.2in}}
\begin{document}

This is my text
\random{\blindtext}
and then my text continues

\end{document}
The idea of random is that it should have equal spacing from the text above and the text below wherever I put it. how should I can do that? my code is not working :( It will be awesome if I can have a horizontal line above and below the random text.

Recommended reading 2024:

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

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

jhapk
Posts: 81
Joined: Tue Apr 20, 2010 9:33 pm

New command "random"

Post by jhapk »

This works

Code: Select all

\newcommand{\random}[1]{\noindent\rule{\textwidth}{0.4pt}\newline{#1}\newline\noindent\rule{\textwidth}{\
0.4pt}\vspace{0.2in}}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

New command "random"

Post by Johannes_B »

Hi,

what are you trying to achieve? Packages like tcolorbox or mdframed can do that for you.
If you don't want to use those, i suggest to define an environment instead of a command. What happens with pagebreaks?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
jhapk
Posts: 81
Joined: Tue Apr 20, 2010 9:33 pm

Re: New command "random"

Post by jhapk »

oh! wow!! these two packages are awesome. thanks a lot.
Post Reply