1

I have the following code:

\documentclass[parskip=half-]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[]{microtype}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{ragged2e}
\usepackage{makecell,xltabular}

\justifying

\geometry{
 a4paper,
%  includeheadfoot,
 left=15mm,
 right=15mm,
 top=25mm,
 bottom=25mm,
 }
 \usepackage[headsepline,plainheadsepline,manualmark]{scrlayer-scrpage}

\usepackage[bottom]{footmisc}


\begin{document}

\ttfamily

\begin{xltabular}{\linewidth}{|p{0.2\linewidth}p{0.2\linewidth}lX|}
  \hline {\bfseries Address} & {\bfseries Name} & {\bfseries Value} & {\bfseries Description}\\\hline\hline\endfirsthead
  \multicolumn{4}{r}{continued from previous page} \\
  \hline {\bfseries Address} & {\bfseries Name} & {\bfseries Value} & {\bfseries Description}\\\hline\hline\endhead
  \multicolumn{4}{r}{continued on next page} \\\endfoot
\endlastfoot
  0x0000 & \hyperref[mylabel]{AAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBB} & 0x00000000 & General purpose control register General purpose control register General purpose control register General purpose control register\\\hline
\end{xltabular}

\label{mylabel}


\end{document}

The second column has a long word that is not wrapped.

How do I make it wrap and be contained within the cell? I also don't want the hyphenation character to be attached.

1 Answer 1

1

I suggest you either load the seqsplit package and encase the long string in a \seqsplit directive or load the xurl package and encase the long string in a \path directive; \nolinkurl works too.

enter image description here

\documentclass[parskip=half-]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage{geometry}
\usepackage{ragged2e}
\usepackage{makecell,xltabular}

\justifying

\geometry{a4paper,left=15mm,right=15mm,vmargin=25mm}
\usepackage[headsepline,plainheadsepline,manualmark]{scrlayer-scrpage}
\usepackage[bottom]{footmisc}

%% new instructions
\newcolumntype{L}{>{\RaggedRight}X}
\newcolumntype{P}[1]{>{\RaggedRight}p{#1\linewidth}}
\usepackage{seqsplit} % <-- new
\usepackage{xurl}     % <-- new
\usepackage{hyperref} % <-- load this package last

\begin{document}

\ttfamily

\begin{xltabular}{\linewidth}{| P{0.2} P{0.2} l L |}

%% headers and footers
  \hline 
  \textbf{Address} & \textbf{Name} & \textbf{Value} & \textbf{Description}\\
  \hline\hline
  \endfirsthead
  
  \multicolumn{4}{@{}l}{(continued from previous page)} \\
  \hline 
  \textbf{Address} & \textbf{Name} & \textbf{Value} & \textbf{Description}\\
  \hline\hline
  \endhead
  
  \hline
  \multicolumn{4}{r@{}}{(continued on next page)} \\
  \endfoot
  
  \hline
  \endlastfoot
  
%% body of table
  0x0000 
  & \hyperref[mylabel]{\seqsplit{AAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBB}} 
  & 0x00000000 
  & General purpose control register 
    General purpose control register 
    General purpose control register 
    General purpose control register\\
  \hline
  0x0000 
  & \hyperref[mylabel]{\path{AAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBB}} 
  & 0x00000000 
  & General purpose control register 
    General purpose control register 
    General purpose control register 
    General purpose control register\\

\end{xltabular}

\label{mylabel} % <-- this instruction won't be associated with the table
                %     unless you also provide a \caption directive

\end{document}
1
  • Thank you very much!
    – Michael
    Aug 25, 2021 at 12:47

You must log in to answer this question.

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