0

I'm currently working on a rough template to write RPG modules from scratch and I would like to create a colored box to highlight some details of the module.

What I'm currently doing is creating the box as a new command with three arguments: the box position (bottom b as default), the title of the box and the text body. The command creates a colorbox and inside it a parbox with the title and body.

The issues I'm having are (1) it compiles, but the command is not using the position argument as I want (it appears right where I place it), and (2) the text does not wrap the box.

I provide a MWE below. Note that I used a lot of dummy text not as \lipsum because I want to put the box between real text.

\documentclass[twoside, letterpaper, 10pt]{article}

\usepackage{fontspec}
\setmainfont{XCharter}

% list of packages
\usepackage[dvipsnames]{xcolor} % Colors
\usepackage{multicol}           % To write text in two columns
\usepackage{titlesec}           % Use to format (sub)section titles
\usepackage[left=1.25in, right=1.25in, top=1in, bottom=1.0625in, columnsep=0.25in]{geometry}    % To set geometry parameters

% set other geometry parameteres not covered by the 'geometry' package
\setlength{\parindent}{2mm}

% user-defined title and game
\def\Titulo*{Campaign Title}%
\def\Subtitulo*{Subtitle}%
\def\Juego*{RPG Game}%

% title creation
\title{\vspace{-1cm}\huge\textbf{\Titulo*}}
\author{
    \large
    \textsc{\Subtitulo*}\\[2mm] %Subtitle
    %\small Theah, 1668, tercer Amordi del mes de Primus.
    %\vspace{-5mm}
}
\date{}

% custom environment: a colored box
\newcommand{\micaja}[3][b]{
    \vspace{\baselineskip}
    \noindent
    \colorbox{BrickRed}{\parbox[#1]{0.46\textwidth}{ \color{white}{\textbf{#2}\\ {\small #3}} }}
    \vspace{\baselineskip}
}

\begin{document}

\maketitle

\begin{multicols}{2} % Two-column layout throughout the main article text

    \section*{Introduction} 

    Lorem ipsum dolor sit amet, at solet definitiones eam. Brute placerat pro te, sed at duis audiam luptatum, at quidam aperiri maiorum mea. Mollis placerat quo id, usu ne errem similique ullamcorper. Usu augue possit reformidans ei, omnesque tractatos imperdiet cu mea. Illum omnesque senserit nec ne, ea sea facete quaeque eruditi.

    Simul menandri necessitatibus vix no, mei saepe semper euripidis ea. Ius elit natum torquatos in, ea prompta saperet consulatu pro. Te simul volutpat pro, ius illum perfecto moderatius ei. Ius dictas saperet luptatum ut, duo id modo causae. Sea tota omnis singulis te, option qualisque his at. Ea repudiare interesset nec, nec an erant pertinax repudiandae.

    Ignota detracto ne ius, te qui voluptatum sadipscing. Ei assentior argumentum vis. Epicuri nostrum delectus vis id, ad malorum detracto voluptatibus vim. Porro interesset vel ex. Ut est habemus eligendi tractatos, quo ea menandri similique. Te est ignota cetero phaedrum, in audire sadipscing has.

    Adhuc movet vis et, has ludus affert platonem ut. Aeque dicam disputationi nec an, his enim facilisis in. Duis brute tamquam at sea, no idque omnesque pri. Ex cum amet recteque. Deserunt splendide ea vis.

    Liber lobortis mea in, ex eirmod forensibus nec, at atqui consul ocurreret cum. Amet autem constituto ne est. Assum graeci nemore an quo, ea saperet accommodare duo. Insolens ocurreret vel ut.

    \section*{Section 1}

    Blandit copiosae an sit, unum maiorum eu qui. Mea te illud soluta tacimates. Alienum urbanitas vim ne, his ferri intellegat pertinacia cu. An sea velit bonorum probatus, et alii vide aeterno duo, delenit scaevola quo cu.

    Cum an erat dolores. Vis no facilis officiis, eu pro dicta consequat. Saepe impetus in quo, ius an wisi maluisset. Te nam mucius doctus virtute, urbanitas maiestatis argumentum ea nec.

    Vis novum vivendum omittantur no, iusto soleat cotidieque et ius. Audiam suscipiantur mei ei, ut sit iudico prompta sanctus. Lorem populo duo ut. Utinam patrioque est et, eam ex delenit luptatum, vim in minimum percipitur. At cum nisl melius.

    An mutat aliquip suscipit usu. Sed dicit congue cu, duo ea ferri ignota saperet, nulla graeci dolorum an vix. Eu nibh suscipit adipisci his, nam te ceteros nostrum epicurei. Nam euripidis honestatis ei. Simul omnium dissentiet eos ea. An dicit impetus volumus eam.

    Vis magna munere vituperatoribus ea, sea deserunt percipitur adversarium ad. Vis eripuit dolorum cotidieque ad, his scripta aliquando cu. Nulla legimus philosophia ea sea. Mea solet noluisse disputando cu, vel cu soleat nostro constituto.

    \micaja[t]{Box title}{This is the box body text, in which I highlight relevant information.}

    Graecis postulant pro id. Ad ferri timeam quo. Eam scripta labitur detracto ea, impetus disputando eam ea. Graeci torquatos adipiscing ea quo, eam ex convenire disputationi.

    Mel suas laoreet ex, usu tempor gloriatur et. Vis unum omnium labitur id. Mollis alterum deterruisset mel cu, ex quo melius probatus atomorum, et graeco disputationi vix. No aperiam elaboraret vis, mel aliquid vivendum in, ex deserunt iracundia sed.

    Eam ei fastidii expetendis, et vix regione quaerendum. Albucius democritum ex vim. Per fastidii instructior comprehensam te, graeco consetetur comprehensam ei vix. Tale sumo accumsan usu id, ea augue luptatum honestatis pro, quem blandit vel in.

\end{multicols}

\end{document}
  • The [b] option of parbox is only important if something else is on the same line. If you want it to work like figure or table, you need to use a float: either figure or table or create a new float (float package). – John Kormylo Dec 1 '17 at 4:32
  • Like John already wrote, the position argument of \parbox is not a page placement but a vertical alignment (use the first or last line inside the paragraph for alignment with outer text on the same baseline). For the spacing and coloring I recommend you to check out the adjustbox package. – Martin Scharrer Dec 1 '17 at 9:48
  • 1
    Using floats here will actually be difficult because of the multicols environment. – Martin Scharrer Dec 1 '17 at 10:10

Your Answer

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

Browse other questions tagged or ask your own question.