GeneralMaking formated frame equal to source frame using LTXexample

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

Making formated frame equal to source frame using LTXexample

Post by yoyoimut »

Dear all,

I am using showexpl package.

If the attribute "frame" is enabled (frame=single) then the frame enclosing code becomes larger than the frame enclosing the formated text.

However, when I disable it, both frames have the same size.
Please see my screen shot below.

I want to enable the frame such that both frames are equal to the text width.
Do you have any idea to do this?
marginshowexpl.jpg
marginshowexpl.jpg (50.28 KiB) Viewed 1430 times

Code: Select all

\documentclass{article}
\setlength{\textwidth}{8cm}
\usepackage{xcolor}

\usepackage{showexpl}
\lstset{%
	backgroundcolor=\color{yellow},
	frame=single,	
	framesep=\fboxsep,
	framerule=1pt,
	rulecolor=\color{red},
	xleftmargin=2\fboxsep, 	% no affect for LTXexample.
	xrightmargin=2\fboxsep,	% no affect for LTXexample.
	language=[LaTeX]TeX,
	explpreset={pos=b,vsep=\fboxsep}%
}


\newcommand{\Marker}{\noindent\strut\vrule\hrulefill~\scriptsize{\color{blue}text width}~\hrulefill\vrule}

\begin{document}
\section{Frame is enabled}
\Marker
\begin{LTXexample}
frame is enabled.
\end{LTXexample}
\Marker

\section{Frame is disabled}
\Marker
\begin{LTXexample}[frame=none]
frame is disabled.
\end{LTXexample}
\Marker
\end{document}

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply