Hot answers tagged

6

Depending on how you want the variables to be broken, you can define a macro that allows breaking with certain rules. Here I just allowed breaking after _. Apart from that, you use a more semantic command that you can redefine with flexibility. \documentclass{report} \newcommand*\ttvar[1]{\texttt{\expandafter\dottvar\detokenize{#1}\relax}} \newcommand*\...


5

This ought to be a kern, rather than a skip; no line break can happen at a kern, unless it is followed by a discardable item (such as a skip). \documentclass[nobib]{tufte-book} % Macros for typesetting the documentation \newcommand{\hairsp}{\leavevmode\kern1pt }% hair space \newcommand{\ie}{\textit{i.\hairsp e.\@}} \newcommand{\eg}{\textit{e.\hairsp g.\@}} ...


4

It's easy to do with the url package. I define a \longvar command which does the job: \documentclass{report} \usepackage{url} \newcommand\longvar[1]{\mathchardef\UrlBreakPenalty=100 \mathchardef\UrlBigBreakPenalty=100\url{#1}} \begin{document} Most of the time, LaTeX line-wrapping works fine. However, sometimes when I'm writing about code with lots and ...


4

there are probably better ways to do this, but if you put \nolinebreak before the \hspace in the definition of \hairsp that will prevent a break any time the macro is used. \newcommand{\hairsp}{\nolinebreak\hspace{1pt}}% hair space


2

Based on the answers to this question Line wrapping on narrow pages it seems that the best way to do this is to wrap the offending paragraph in a sloppypar environment. \documentclass{report} \begin{document} \begin{sloppypar} Most of the time, LaTeX line-wrapping works fine. However, sometimes when I'm writing about code with lots of \texttt{long\...


2

You need an updated version of \@makechapterhead since the current one doesn't allow for the line breaks since it uses \centerline. Instead using \centering: \def\@makechapterhead#1{% % \vspace*{50\p@}% {\parindent \z@ \raggedright \normalfont \centering \ifnum \c@secnumdepth >\m@ne \large\bfseries \@chapapp\space \thechapter \...


2

I guess that with \n you are meaning a “new line”. Since file systems can do different things to files, TeX always adds an implicit end-of-line character at the end of input files. Here I'll talk about the primitive \input. So your foo1.tex file can be seen to contain B<newline>, foo2.tex contains B%<newline> and foo3.tex has B<newline>%&...


1

I would do it this way, with tabularx. This is a case where vertical rules are preferred, in my opinion. I changed the alignment of the first column to r, and used the showframe option of geometry to check it each row fits within the margins: \documentclass[a4paper, x11names]{article} \usepackage[showframe]{geometry} \usepackage{array, tabularx} \usepackage[...


1

You can always check with \ifvmode or \ifhmode, e.g., \ifvmode do this\else do that\fi. But here you don't need that because \par acts that way (don't use \newline or \\ to end paragraphs). I added the \noindent which does no harm if \parskip=0pt and acts as you seem to want when \parskip≠0pt. \newenvironment{myenv} {\begin{trivlist}\item} {\par\...


1

here is a solution, one can use \\, \par or blanck line. \noindent works fine inside arabtext environment \documentclass[10pt,a4paper]{report} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{arabtex} % caption must be loaded before arabtex \usepackage{utf8} \begin{document} \setcode{utf8} \begin{arabtext} \large خلال الأربعينات، مع تطوير ...


1

The argument to \underline cannot be broken across lines. You can do it with ulem: \documentclass[a4paper, 11pt]{article} \usepackage[normalem]{ulem} \usepackage{titlesec} \titleformat{\section}{\Large\centering}{}{0em}{\uline} \begin{document} \section{Very Long very long very long very \\ long very long very long Title} Text text text \end{document}


1

For what it's worth, you're working with a limited set of TeX functionality known as MathJax. Specifically you're forced to use a math environment, within which the following setup works: \begin{array}{l} \text{If $\dfrac{x-3}{3} = k$ and $k = 3$, what is the value of $x$?} \\ \text{A) 2} \\ \text{B) 4} \\ \text{C) 9} \\ \text{D) 10} \end{array}


1

A variation on \filbreak (The TeXbook, page 111): \documentclass{article} \usepackage{xcolor} \usepackage{showframe} \newcommand{\class}[1]{% \hfil\penalty0 \hfilneg \textcolor{red}{\texttt{#1}}% } \begin{document} Here is an example of long text given to class \class{SomeVeryLongClassNameThatNeedsToBePushedToTheNextLine} and text after it and a \...


1

I think the problem is related to what is described here: How to automatically hyphenate within \texttt?. Applying that solution to your class macro yields the desired results: Notes: The showframe package was used just to show the page margins. It is not needed in your actual use case. Code: \documentclass{article} \usepackage{xcolor} \usepackage{...


1

To have label and title on the same line, use the block style, and the command \filleft as the first mandatory argument (global settings): \documentclass[a4paper]{report} \usepackage[T1]{fontenc}% \usepackage{geometry}%% \usepackage{garamondx}% \usepackage{xcolor} \usepackage{titlesec} \titleformat{\chapter}[block]% {\bfseries\Large\filleft}% {\fontsize{60}...



Only top voted, non community-wiki answers of a minimum length are eligible